I am using the development version Elixir with SQLAlchemy-0.4.5 and
python 2.4 on Linux, connecting to a Firebird 2.1 database with
kinterbasdb-3.2.2 .
My current model seems valid as I can run "tg-admin sql create", but I
have noticed that I'm not getting any Sequences created on the Primary
Keys.
Similarly when I try to create objects from my model, I am getting an
error caused by a NULL id value in the INSERT statement.
I get the same behaviour whether options_defaults['autoincrement'] is
set to True or False.
I have also replicated this behaviour with a new project with identity
support, generated with "tg-admin quickstart --elixir".
What should I be setting in my models.py Elixir, to ensure that I
should be specifying to ensure that sequences are created for primary
keys and that they are used in INSERT statements.
[EMAIL PROTECTED] Project1]$ tg-admin shell
Python 2.4.4 (#5, Apr 1 2008, 17:30:16)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(CustomShell)
>>> from model import User
>>> from datetime import datetime
>>> test_user = User(user_name=u'Test', email_address=u'[EMAIL PROTECTED]',
>>> display_name=u'Test User', password=u'w00t', created=datetime.now())
>>> test_user.save()
>>>
>>> Do you wish to commit your database changes? [yes]yes
2008-10-22 15:38:35,712 sqlalchemy.engine.base.Engine.0x..b4 INFO
BEGIN
2008-10-22 15:38:35,716 sqlalchemy.engine.base.Engine.0x..b4 INFO
INSERT INTO tg_user (user_id, user_name, email_address, display_name,
"password", created) VALUES (?, ?, ?, ?, ?, ?)
2008-10-22 15:38:35,716 sqlalchemy.engine.base.Engine.0x..b4 INFO
[None, 'Test', '[EMAIL PROTECTED]', 'Test User', 'w00t',
datetime.datetime(2008, 10, 22, 15, 38, 13, 412425)]
2008-10-22 15:38:35,720 sqlalchemy.engine.base.Engine.0x..b4 INFO
ROLLBACK
Traceback (most recent call last):
File "<console>", line 1, in ?
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/scoping.py", line 98, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/session.py", line 757, in flush
self.uow.flush(self, objects)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/unitofwork.py", line 233, in flush
flush_context.execute()
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/unitofwork.py", line 445, in execute
UOWExecutor().execute(self, tasks)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/unitofwork.py", line 930, in execute
self.execute_save_steps(trans, task)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/unitofwork.py", line 945, in
execute_save_steps
self.save_objects(trans, task)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/unitofwork.py", line 936, in save_objects
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/orm/mapper.py", line 1150, in _save_obj
c = connection.execute(statement.values(value_params), params)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 844, in execute
return Connection.executors[c](self, object, multiparams, params)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 895, in
execute_clauseelement
return self._execute_compiled(elem.compile(dialect=self.dialect,
column_keys=keys, inline=len(params) > 1), distilled_params=params)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 907, in _execute_compiled
self.__execute_raw(context)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 916, in __execute_raw
self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 960, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.4.5-
py2.4.egg/sqlalchemy/engine/base.py", line 942, in
_handle_dbapi_exception
raise exceptions.DBAPIError.instance(statement, parameters, e,
connection_invalidated=is_disconnect)
ProgrammingError: (ProgrammingError) (-625, 'isc_dsql_execute: \n
validation error for column USER_ID, value "*** null ***"') 'INSERT
INTO tg_user (user_id, user_name, email_address, display_name,
"password", created) VALUES (?, ?, ?, ?, ?, ?)' [None, 'Test',
'[EMAIL PROTECTED]', 'Test User', 'w00t', datetime.datetime(2008, 10,
22, 15, 38, 13, 412425)]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---