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

Error not thrown when entering wrong db path #26

Closed
DaasDaham opened this issue Mar 1, 2020 · 0 comments
Closed

Error not thrown when entering wrong db path #26

DaasDaham opened this issue Mar 1, 2020 · 0 comments

Comments

@DaasDaham
Copy link
Contributor

DaasDaham commented Mar 1, 2020

  • pysradb version:0.10.2
  • Python version:3.6.9
  • Operating System:Ubuntu

Description

If SRAmetadab.sqlite is not already downloaded on local machine using $ pysradb metadb, then when using db = SRAdb('xyz.sqlite') throws an exception metaInfo not found which is hard-coded on line 158 in sradb.py. Ideally, it should check if the file with the name entered already exists or not and throw the error on line 153 in sradp.py not a valid SRAmetadb.sqlite file. It, however, creates a new .sqlite file with the given address ('xyz.sqlite' in this case) and tries SELECT * from metaInfo on it. Therefore, it would never enter the except block on line 153.

What I Did

from pysradb import SRAdb
db = SRAdb('this_shouldnt_exist')
df = db.sra_metadata('SRP098789')
df.head()

It returns

Traceback (most recent call last):
  File "sample.py", line 2, in <module>
    db = SRAdb('this_shouldnt_exist')
  File "/usr/local/lib/python3.6/dist-packages/pysradb/sradb.py", line 178, in __init__
    _verify_srametadb(sqlite_file)
  File "/usr/local/lib/python3.6/dist-packages/pysradb/sradb.py", line 155, in _verify_srametadb
    metadata = db.query("SELECT * FROM metaInfo")
  File "/usr/local/lib/python3.6/dist-packages/pysradb/basedb.py", line 103, in query
    results = self.cursor.execute(sql_query).fetchall()
sqlite3.OperationalError: no such table: metaInfo

and doing an ls on current dir shows the file with the name entered has been created

saad@DaasDaham:~$ ls
Desktop    examples.desktop  Public             sample.py  this_shouldnt_exist
Documents  Music             pysradb_downloads  snap       Videos
Downloads  Pictures          R                  Templates
DaasDaham pushed a commit to DaasDaham/pysradb that referenced this issue Mar 2, 2020
DaasDaham pushed a commit to DaasDaham/pysradb that referenced this issue Mar 2, 2020
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