I'm trying to connect to a database from python, running in a debian based docker container. I extracted the bit of code that's causing the failure:
import sqlalchemy
from db_tools import generate_sandbox_connection
con = generate_sandbox_connection('churn', 'PASSWORD')
metadata = sqlalchemy.MetaData()
report_lookup = sqlalchemy.Table('REPORT_LOOKUP',
metadata,
schema = 'SCHEMA',
autoload = True,
autoload_with = con)
This causes the following output:
Traceback (most recent call last):
File "sqlalchemytest.py", line 43, in <module>
autoload_with = sandb_con)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 457, in __new__
metadata._remove_table(name, schema)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 452, in __new__
table._init(name, metadata, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 534, in _init
include_columns, _extend_on=_extend_on)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 547, in _autoload
_extend_on=_extend_on
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2056, in run_callable
...
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (cx_Oracle.ProgrammingError) positional and named binds cannot be intermixed [SQL: u'SELECT table_name, compression, compress_for FROM ALL_TABLES WHERE table_name = :table_name AND owner = :owner '] [parameters: {'owner': u'TRIP', 'table_name': u'CHURN_REPORT_LOOKUP'}] (Background on this error at: http://sqlalche.me/e/f405)
Anyone know how to fix this? It runs just fine on my local machine but it's breaking down in the docker instance.
It is a known bug in latest v6.4
:
https://github.com/oracle/python-cx_Oracle/issues/199
For now, and until v6.4.1
is available, just downgrade to v6.3.1
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.