Hello All,
I'm trying to use transactions without object mappers.
From the documentation I can see that I need to create a transaction
object. However if I do this I get the following behavior: from sqlalchemy import * meta = BoundMetaData("sqlite://") users = Table("users", meta, Column("login", String, primary_key=1), Column("uid", Integer)) users.create() connection = users.engine.connect() session = create_session(bind_to=connection) trans = connection.begin() for i in range(10): connection.execute(users.insert(), login="login%d" % i, uid=i) # Notice we didn't commit yet for row in users.select().execute(): print row # We will get the output #(u'login0', 0) #(u'login1', 1) #(u'login2', 2) #(u'login3', 3) #(u'login4', 4) #(u'login5', 5) #(u'login6', 6) #(u'login7', 7) #(u'login8', 8) #(u'login9', 9) This means that if someone is querying the table in the middle of the transaction it'll get wrong results. (I'm not a DB expert, this might be total nonsense) Next, I tried to simplify the transaction by executing "BEGIN" and "END", I get this strange error: from sqlalchemy import * meta = BoundMetaData("sqlite://") users = Table("users", meta, Column("login", String, primary_key=1), Column("uid", Integer)) users.create() users.engine.execute("BEGIN") for i in range(10): # This will raise users.insert().execute(login="login%d" % i, uid=i) users.engine.execute("END") Got me the error: Traceback (most recent call last): File "trans.py", line 9, in <module> users.insert().execute(login="login%d" % i, uid=i) File "build/bdist.linux-i686/egg/sqlalchemy/sql.py", line 474, in execute File "build/bdist.linux-i686/egg/sqlalchemy/sql.py", line 412, in execute File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 484, in execute_compiled File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 295, in execute_compiled File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 291, in proxy File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 329, in _execute_raw File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 348, in _execute sqlalchemy.exceptions.SQLError: (OperationalError) SQL logic error or missing database 'INSERT INTO users (login, uid) VALUES (?, ?)' ['login0', 0] Any ideas on how to solve this? Thanks, Miki --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---