ODM2 / ODM2PythonAPI

A set of Python functions that provides data read/write access to an ODM2 database by leveraging SQLAlchemy.
http://odm2.github.io/ODM2PythonAPI/
BSD 3-Clause "New" or "Revised" License
4 stars 13 forks source link

creating tables via sqlalchemy model base in sqlite #25

Open cdesyoun opened 8 years ago

cdesyoun commented 8 years ago

I tried to create all of tables via ODM2 model base, like this:

from odm2api.base import *
modelBase.metadata.create_all(engine)

in current odm2 sqlalchemy model, because of table schema, "odm2", when creating tables in sqlite, I got the error message below:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unknown database "odm2" [SQL: u'PRAGMA "odm2".table_info("samplingfeatureexternalidentifiers")']

When using the modified odm2 model for sqlite, https://github.com/ODM2/ODM2PythonAPI/blob/master/odm2api/ODM2/models_sqlite.py, it went well. Is there any way to skip the schema tag in current odm2 sqlalchemy model for not supporting the schema in certain databases, sqlite, mySQL?

horsburgh commented 8 years ago

@cdesyoun - I don't know the answer to this question, but I do know that @sreeder has had some similar issues with SQLite and I thought had figured out how to turn off the "odm2" schema for anything to do with SQLite. She will have to confirm. She's on maternity leave for a few more weeks.

In the meantime, to create an ODM2 SQLite database, you should use the blank schema script from the ODM2 repository for SQLite:

https://github.com/ODM2/ODM2/tree/master/src/blank_schema_scripts