Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

itsdb function to check if a table is non-empty #112

Closed
goodmami opened this issue May 31, 2017 · 0 comments
Closed

itsdb function to check if a table is non-empty #112

goodmami opened this issue May 31, 2017 · 0 comments

Comments

@goodmami
Copy link
Member

When reading tables using ItsdbProfile.read_table(), it will raise a KeyError for a table not defined in the relations, raise a ItsdbError if the table is defined, but there is no corresponding file, or return a list of rows for a present, defined file (an empty list for an empty file). Furthermore, because files can be plaintext or compressed, to check if a file is present is a bit clunky:

filepath = os.path.join(p.root, tablename)
if os.path.exists(filepath) or os.path.exists(filepath + '.gz'):
  ...

Similarly, to check if the file is non-empty:

if (os.path.exists(filepath) and os.stat(filepath).st_size > 0) or (os.path.exists(filepath + '.gz') and os.stat(filepath + '.gz') > 0):
  ...

These would be more convenient if the ItsdbProfile class had some table_exists() and table_size() (or table_nonempty() or something) methods. In general, the user should not have to manage the filepath and filepath + '.gz' alternations themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant