crate / sqlalchemy-cratedb

SQLAlchemy dialect for CrateDB.
https://cratedb.com/docs/sqlalchemy-cratedb/
Apache License 2.0
3 stars 2 forks source link

Sqlalchemy compatibility issues #73

Closed zopyx closed 9 years ago

zopyx commented 9 years ago

Just had the (crazy) idea to try out Kotti CMS with Crate.

I configured the DB URL in Kotii as

sqlalchemy.url = crate://dev1.veit-schiele.de:4200/

Failure crate/crate-python#1:

Suxmac:mysite ajung$ bin/pserve app.ini Traceback (most recent call last): File "bin/pserve", line 11, in sys.exit(main()) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 51, in main return command.run() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 316, in run global_conf=vars) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 340, in loadapp return loadapp(app_spec, name=name, relative_to=relative_to, _kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp return loadobj(APP, uri, name=name, _kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj return context.create() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create return self.object_type.invoke(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 203, in invoke app = context.app_context.create() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create return self.object_type.invoke(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke return fix_call(context.object, context.global_conf, *_context.local_conf) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call val = callable(_args, kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/kotti/init**.py", line 165, in main initialize_sql(engine) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/kotti/resources.py", line 779, in initialize_sql if not engine.table_names(): File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1813, in table_names schema = self.dialect.default_schema_name AttributeError: 'CrateDialect' object has no attribute 'default_schema_name'


Providing a database as

sqlalchemy.url = crate://dev1.veit-schiele.de:4200/somedb

gives failure crate/crate-python#2:

bin/pserve app.ini Traceback (most recent call last): File "bin/pserve", line 11, in sys.exit(main()) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 51, in main return command.run() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 316, in run global_conf=vars) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 340, in loadapp return loadapp(app_spec, name=name, relative_to=relative_to, _kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp return loadobj(APP, uri, name=name, _kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj return context.create() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create return self.object_type.invoke(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 203, in invoke app = context.app_context.create() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create return self.object_type.invoke(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke return fix_call(context.object, context.global_conf, _context.local_conf) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/util.py", line 58, in fix_call reraise(_exc_info) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/compat.py", line 23, in reraise exec('raise t, e, tb', dict(t=t, e=e, tb=tb)) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call val = callable(_args, _kw) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/kotti/init.py", line 165, in main initialize_sql(engine) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/kotti/resources.py", line 779, in initialize_sql if not engine.table_names(): File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1811, in table_names with self._optional_conn_ctx_manager(connection) as conn: File "/opt/buildout.python/parts/opt/lib/python2.7/contextlib.py", line 17, in enter return self.gen.next() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1608, in _optional_conn_ctx_manager with self.contextual_connect() as conn: File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1798, in contextual_connect self.pool.connect(), File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 338, in connect return _ConnectionFairy._checkout(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 644, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 440, in checkout rec = pool._do_get() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 963, in _do_get return self._create_connection() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 285, in _create_connection return _ConnectionRecord(self) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 411, in init self.connection = self.connect() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/pool.py", line 538, in connect connection = self.__pool._creator() File "/Users/ajung/src/mysite/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 90, in connect return dialect.connect(_cargs, *_cparams) File "/Users/ajung/src/mysite/lib/python2.7/site-packages/crate/client/sqlalchemy/dialect.py", line 143, in connect return self.dbapi.connect(servers=server, **kwargs) TypeError: connect() got an unexpected keyword argument 'database'

chaudum commented 9 years ago

hi @zopyx

the version you first tried is correct. however, it seems that our CrateDialect is missing the default_schema_name attribute. we'll update the driver accordingly!

btw: we support custom schemas since 0.46 (which is currently a testing release)

christian

chaudum commented 9 years ago

hi @zopyx

we've updated our python client containing the missing attribute in the SqlAlchemy CrateDialect https://github.com/crate/crate-python/commit/618b2ccdde2da3cf95ec3ceff62ca46989cd9844

you can get the latest version from our website or directly from pypi https://crate.io/docs/clients/ https://pypi.python.org/pypi/crate/0.12.4