Hi.
I have noted a change in SA 0.4 about compiled queries.
Here is a sample script (it requires PostgreSQL):
from sqlalchemy import engine, schema, sql, types
metadata = schema.MetaData()
test = schema.Table(
'test', metadata,
schema.Column('id', types.Integer, primary_key=True),
schema.Column('x', types.Integer),
)
URL = 'postgres://twisted_test:[EMAIL PROTECTED]/twisted_test'
db = engine.create_engine(URL)
metadata.bind = db
try:
metadata.create_all()
query = test.insert().compile()
r = db.execute(query, x=10)
print r.rowcount
finally:
metadata.drop_all()
I get an exception:
$python compiled.py
Traceback (most recent call last):
File "compiled.py", line 24, in ?
r = db.execute(query, x=10)
File
"/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/engine/base.py",
line 1121, in execute
return connection.execute(statement, *multiparams, **params)
File
"/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/engine/base.py",
line 784, in execute
return Connection.executors[c](self, object, multiparams, params)
File
"/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/engine/base.py",
line 847, in _execute_compiled
self.__execute_raw(context)
File
"/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/engine/base.py",
line 859, in __execute_raw
self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File
"/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/engine/base.py",
line 875, in _cursor_execute
raise exceptions.DBAPIError.instance(statement, parameters, e)
sqlalchemy.exceptions.IntegrityError: (IntegrityError) null value in
column "id" violates not-null constraint
'INSERT INTO test (id, x) VALUES (%(id)s, %(x)s)' {'x': 10, 'id': None}
I'm posting the problem here since I'm not sure if this is a bug or a
feature.
If this is a bug, I will fill a ticket.
Thanks Manlio Perillo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---