-
Notifications
You must be signed in to change notification settings - Fork 35
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
Create abstract interface #61
Comments
Does this mean that we'll be able to move data off from SQLite3? If that's the case, then I can help you with this to speed up the development. That's part of our requirement and I'm just investigating the possibility for that. |
For me the code with DB management seems to be really straightforward and uses mostly Python's DB API. My notes and first review points following non standard DB stuff:
Of course if you want more than "select any SQL database" kind of abstraction, then the code requires a lot more work. But in our case it would be just enough to
|
And after reading it even better it seems that SQLite3 module is used non-standard way. It provides short cut to avoid separate (visible) cursor object. That shortcut is used everywhere. The DB-API 2.0 requires separate use of cursor object. So e.g following is illegal:
This should be:
|
@teemuvesala... Re: Yes, the intention for this issue is to refactor the current sqlite-specific backend into a service interface with multiple implementations (one of which is sqlite). Can you please explain elaborate on your requirements? I would certainly appreciate code contributions if we're aligned on direction. Are you imagining putting sequences in postgresql too? If so, do you have plans for optimizing sequence slicing (e.g., reading a few nucleotides from a chromosome)? Two of your suggestions should be undertaken anyway: 1) db as init arg, and 2) deconstruct the Can you elaborate on your comment about exceptions being ignored? Examples will help. |
Our current requirement (which is almost instant) is to replace the SQLite with PostgreSQL, but long term plan is to get DynamoDB support. So from roadmap perspective good idea would be to 1) Remove SQLite specific code (which is your step 2). I've started it and I'll do. 2) Add support for any Python module which is DB API 2.0 compatible. 3) Add non-SQL-way to do things. File biocommons.seqrepo/src/biocommons/seqrepo/seqaliasdb/seqaliasdb.py has following snippet at function store_alias:
The problem with this snippet is that exception is SQLite specific. But this follows the DB API 2.0 specification correctly. Now if we think that _db is now some other (e.g. imaginarydb) driver, the exception would be imaginarydb.IntegrityError. The only common parent class is Exception. So to support this non-SQLite3-way we'd have to check if the class name of exception has IntegrityError, if it has, then ignore the error, otherwise rise the caught exception. |
Now at my repository is the code which can use also PostgreSQL for database. It needed quite many changes. E.g. parametrisation required changes. At SQLIte the style is |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
seqrepo currently has distinct backends for aliases and sequences. Both are essentially key-value stores.
In order to open up other possibilities (redis, elasticache, federated repo proxy, local cache, etc.), implement abstract classes and subclass for each backend type.
The text was updated successfully, but these errors were encountered: