Skip to content

Instantly share code, notes, and snippets.

@achiang
Created December 14, 2015 04:11
Show Gist options
  • Save achiang/8d4a6e3f495084d6761c to your computer and use it in GitHub Desktop.
Save achiang/8d4a6e3f495084d6761c to your computer and use it in GitHub Desktop.
$ python decl_enum.py
/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/sql/default_comparator.py:153: SAWarning: The IN-predicate on "employee.type" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance.
'strategies for improved performance.' % expr)
2015-12-14 04:09:53,442 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2015-12-14 04:09:53,442 INFO sqlalchemy.engine.base.Engine ()
2015-12-14 04:09:53,443 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2015-12-14 04:09:53,444 INFO sqlalchemy.engine.base.Engine ()
2015-12-14 04:09:53,445 INFO sqlalchemy.engine.base.Engine PRAGMA table_info("employee")
2015-12-14 04:09:53,446 INFO sqlalchemy.engine.base.Engine ()
2015-12-14 04:09:53,447 INFO sqlalchemy.engine.base.Engine
CREATE TABLE employee (
id INTEGER NOT NULL,
name VARCHAR(60) NOT NULL,
type VARCHAR,
PRIMARY KEY (id),
CONSTRAINT ck_employee_type CHECK (type != type)
)
2015-12-14 04:09:53,451 INFO sqlalchemy.engine.base.Engine ()
2015-12-14 04:09:53,452 INFO sqlalchemy.engine.base.Engine COMMIT
2015-12-14 04:09:53,453 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2015-12-14 04:09:53,455 INFO sqlalchemy.engine.base.Engine ROLLBACK
Traceback (most recent call last):
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1073, in _execute_context
context = constructor(dialect, self, conn, *args)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 582, in _init_compiled
param.append(processors[key](compiled_params[key]))
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/sql/type_api.py", line 962, in process
return process_param(value, dialect)
File "decl_enum.py", line 86, in process_bind_param
return value.value
AttributeError: 'tuple' object has no attribute 'value'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "decl_enum.py", line 127, in <module>
sess.commit()
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 801, in commit
self.transaction.commit()
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 392, in commit
self._prepare_impl()
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
self.session.flush()
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2015, in flush
self._flush(objects)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2133, in _flush
transaction.rollback(_capture_exception=True)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 182, in reraise
raise value
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2097, in _flush
flush_context.execute()
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
rec.execute(self)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
uow
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
mapper, table, insert)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 785, in _emit_insert_statements
execute(statement, params)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
compiled_sql, distilled_params
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1078, in _execute_context
None, None)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
exc_info
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 188, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 181, in reraise
raise value.with_traceback(tb)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1073, in _execute_context
context = constructor(dialect, self, conn, *args)
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 582, in _init_compiled
param.append(processors[key](compiled_params[key]))
File "/home/vagrant/venv/lib/python3.4/site-packages/sqlalchemy/sql/type_api.py", line 962, in process
return process_param(value, dialect)
File "decl_enum.py", line 86, in process_bind_param
return value.value
sqlalchemy.exc.StatementError: (builtins.AttributeError) 'tuple' object has no attribute 'value' [SQL: 'INSERT INTO employee (name, type) VALUES (?, ?)'] [parameters: [{'name': 'e1', 'type': ('F', 'Full Time')}]]
$ python --version
Python 3.4.3
$ pip show sqlalchemy
---
Name: SQLAlchemy
Version: 1.0.9
Location: /home/vagrant/venv/lib/python3.4/site-packages
Requires:
$ uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment