Re: [sqlalchemy] Problem inserting records in blob column
Hi, I'm experiencing a similar problem in my program (Sqlalchemy 0.8.4). In my case no blob column is involved, the problem seems to be related to presence of a foreign key in the target table. Here is the traceback of the error: File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 721, in commit self.transaction.commit() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 354, in commit self._prepare_impl() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 334, in _prepare_impl self.session.flush() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1818, in flush self._flush(objects) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1936, in _flush transaction.rollback(_capture_exception=True) File C:\Python27\lib\site-packages\sqlalchemy\util\langhelpers.py, line 58, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1900, in _flush flush_context.execute() File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 372, in execute rec.execute(self) File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 525, in execute uow File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 64, in save_obj table, insert) File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 569, in _emit_insert_statements execute(statement, params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 662, in execute params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 761, in _execute_clauseelement compiled_sql, distilled_params File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 828, in _execute_context None, None) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 1024, in _handle_dbapi_exception exc_info File C:\Python27\lib\site-packages\sqlalchemy\util\compat.py, line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 824, in _execute_context context = constructor(dialect, self, conn, *args) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 446, in _init_compiled self.__process_defaults() File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 821, in __process_defaults val = self.get_insert_default(c) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 777, in get_insert_default return self._exec_default(column.default, column.type) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 761, in _exec_default return self.fire_sequence(default, type_) StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence') u'INSERT INTO dataset (set_id, user_id, label, set_table, nam_table, val_table, datasource, info) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' [{'info': None, 'user_id': 1, 'val_table': u'val_table', 'label': u'tab1', 'nam_tab': u'nam_table', 'set_table': u'tab1', 'datasource': None}] The construct which causes the error is this: dataset.append_constraint(sa.ForeignKeyConstraint([dataset.c.set_id], [task.c.set_id])) If I remove this line of code everything goes well (but of course I cannot set up the relationship between the dataset table and the task table). Any help is really appreciated. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Problem inserting records in blob column
there’s a SQLAlchemy issue here, marked as ticket http://www.sqlalchemy.org/trac/ticket/2896, however resolving this issue still won’t fix your issue. You’re emitting an INSERT on a table where the primary key needs to refer to a column elsewhere. that is: task = Table('y', metadata, Column('set_id', Integer, primary_key=True) ) dataset = Table(x, metadata, Column(set_id, Integer, primary_key=True) ) dataset.append_constraint(ForeignKeyConstraint([dataset.c.set_id], [task.c.set_id])) to insert a dataset row, the dataset must refer to a task row. SQLite doesn’t enforce foreign key constraints by default so that the INSERT will proceed but the row will be relationally inconsistent. also, if you aren’t planning on using Oracle as a backend, I’d remove the Sequence directive from your program for now. until #2896 is fixed it will get in the way of allowing this issue to be clear. On Dec 20, 2013, at 5:50 AM, Massi massi_...@msn.com wrote: Hi, I'm experiencing a similar problem in my program (Sqlalchemy 0.8.4). In my case no blob column is involved, the problem seems to be related to presence of a foreign key in the target table. Here is the traceback of the error: File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 721, in commit self.transaction.commit() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 354, in commit self._prepare_impl() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 334, in _prepare_impl self.session.flush() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1818, in flush self._flush(objects) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1936, in _flush transaction.rollback(_capture_exception=True) File C:\Python27\lib\site-packages\sqlalchemy\util\langhelpers.py, line 58, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1900, in _flush flush_context.execute() File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 372, in execute rec.execute(self) File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 525, in execute uow File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 64, in save_obj table, insert) File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 569, in _emit_insert_statements execute(statement, params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 662, in execute params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 761, in _execute_clauseelement compiled_sql, distilled_params File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 828, in _execute_context None, None) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 1024, in _handle_dbapi_exception exc_info File C:\Python27\lib\site-packages\sqlalchemy\util\compat.py, line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 824, in _execute_context context = constructor(dialect, self, conn, *args) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 446, in _init_compiled self.__process_defaults() File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 821, in __process_defaults val = self.get_insert_default(c) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 777, in get_insert_default return self._exec_default(column.default, column.type) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 761, in _exec_default return self.fire_sequence(default, type_) StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence') u'INSERT INTO dataset (set_id, user_id, label, set_table, nam_table, val_table, datasource, info) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' [{'info': None, 'user_id': 1, 'val_table': u'val_table', 'label': u'tab1', 'nam_tab': u'nam_table', 'set_table': u'tab1', 'datasource': None}] The construct which causes the error is this: dataset.append_constraint(sa.ForeignKeyConstraint([dataset.c.set_id], [task.c.set_id])) If I remove this line of code everything goes well (but of course I cannot set up the relationship between the dataset table and the task table). Any help is really appreciated. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit
Re: [sqlalchemy] Problem inserting records in blob column
issue #2896 is resolved for 0.8.5 and 0.9.0. On Dec 20, 2013, at 10:03 AM, Michael Bayer mike...@zzzcomputing.com wrote: there’s a SQLAlchemy issue here, marked as ticket http://www.sqlalchemy.org/trac/ticket/2896, however resolving this issue still won’t fix your issue. You’re emitting an INSERT on a table where the primary key needs to refer to a column elsewhere. that is: task = Table('y', metadata, Column('set_id', Integer, primary_key=True) ) dataset = Table(x, metadata, Column(set_id, Integer, primary_key=True) ) dataset.append_constraint(ForeignKeyConstraint([dataset.c.set_id], [task.c.set_id])) to insert a dataset row, the dataset must refer to a task row. SQLite doesn’t enforce foreign key constraints by default so that the INSERT will proceed but the row will be relationally inconsistent. also, if you aren’t planning on using Oracle as a backend, I’d remove the Sequence directive from your program for now. until #2896 is fixed it will get in the way of allowing this issue to be clear. On Dec 20, 2013, at 5:50 AM, Massi massi_...@msn.com wrote: Hi, I'm experiencing a similar problem in my program (Sqlalchemy 0.8.4). In my case no blob column is involved, the problem seems to be related to presence of a foreign key in the target table. Here is the traceback of the error: File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 721, in commit self.transaction.commit() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 354, in commit self._prepare_impl() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 334, in _prepare_impl self.session.flush() File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1818, in flush self._flush(objects) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1936, in _flush transaction.rollback(_capture_exception=True) File C:\Python27\lib\site-packages\sqlalchemy\util\langhelpers.py, line 58, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py, line 1900, in _flush flush_context.execute() File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 372, in execute rec.execute(self) File C:\Python27\lib\site-packages\sqlalchemy\orm\unitofwork.py, line 525, in execute uow File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 64, in save_obj table, insert) File C:\Python27\lib\site-packages\sqlalchemy\orm\persistence.py, line 569, in _emit_insert_statements execute(statement, params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 662, in execute params) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 761, in _execute_clauseelement compiled_sql, distilled_params File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 828, in _execute_context None, None) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 1024, in _handle_dbapi_exception exc_info File C:\Python27\lib\site-packages\sqlalchemy\util\compat.py, line 196, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File C:\Python27\lib\site-packages\sqlalchemy\engine\base.py, line 824, in _execute_context context = constructor(dialect, self, conn, *args) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 446, in _init_compiled self.__process_defaults() File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 821, in __process_defaults val = self.get_insert_default(c) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 777, in get_insert_default return self._exec_default(column.default, column.type) File C:\Python27\lib\site-packages\sqlalchemy\engine\default.py, line 761, in _exec_default return self.fire_sequence(default, type_) StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence') u'INSERT INTO dataset (set_id, user_id, label, set_table, nam_table, val_table, datasource, info) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' [{'info': None, 'user_id': 1, 'val_table': u'val_table', 'label': u'tab1', 'nam_tab': u'nam_table', 'set_table': u'tab1', 'datasource': None}] The construct which causes the error is this: dataset.append_constraint(sa.ForeignKeyConstraint([dataset.c.set_id], [task.c.set_id])) If I remove this line of code everything goes well (but of course I cannot set up the relationship between the dataset table and the task table). Any help is really appreciated. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving
[sqlalchemy] Problem inserting records in blob column
Hi everyone, I'm using SQLalchemy 0.7.10 and I'm encountering some problems trying to insert records inside a table in a blob column. The error I get is the following: StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence') 'INSERT INTO r_2_sti (id, iter, data) VALUES (?, ?, ?)' [{'data': 'wer', 'iter': -1}] It's quite difficult for me to build a test case of the error, since it happens inside a large program, but in general the code that generates the error is something like this: from sqlalchemy import * engine = create_engine('sqlite:///test.db', echo=True) m = MetaData() t = Table('t', m, Column('data', LargeBinary)) m.create_all(engine) engine.execute(t.insert(), {'data':b'abc'}, {'data':b'xyz'}) The problem is that the example code perfectly works! So, does anyone has an idea of what I am possibly doing wrong? Thanks in advance! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Problem inserting records in blob column
On Sep 19, 2013, at 11:09 AM, erikamont...@libero.it wrote: Hi everyone, I'm using SQLalchemy 0.7.10 and I'm encountering some problems trying to insert records inside a table in a blob column. The error I get is the following: StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence') 'INSERT INTO r_2_sti (id, iter, data) VALUES (?, ?, ?)' [{'data': 'wer', 'iter': -1}] It's quite difficult for me to build a test case of the error, since it happens inside a large program, but in general the code that generates the error is something like this: from sqlalchemy import * engine = create_engine('sqlite:///test.db', echo=True) m = MetaData() t = Table('t', m, Column('data', LargeBinary)) m.create_all(engine) engine.execute(t.insert(), {'data':b'abc'}, {'data':b'xyz'}) The problem is that the example code perfectly works! So, does anyone has an idea of what I am possibly doing wrong? Thanks in advance! you might have a Sequence() construct listed as a default somewhere, it's not clear. a stack trace would say more, but I think searching for the term Sequence would be the first course of action. signature.asc Description: Message signed with OpenPGP using GPGMail