Thanks, Mike.
On Thursday, March 27, 2014 3:16:27 PM UTC-4, Michael Bayer wrote:
...
> OK, you seem to have found the autocommit flag on text(), this is the
> correct approach in this case.
>
> I can’t get your stored proc to run as creating a proc on my machine
> produces some “thread stack overrun” error I don’t have the time to figure
> out, but a simple test of just a SELECT with autocommit=True illustrates
> the COMMIT being called in the log:
>
>
...
> can’t reproduce - test script:
>
> from sqlalchemy import *
>
> e = create_engine("mysql://scott:tiger@localhost/test",
> echo=True).execution_options(autocommit=True)
>
> r = e.execute(text('SELECT 1’))
>
> output, includes the COMMIT as expected:
>
> 2014-03-27 15:11:14,324 INFO sqlalchemy.engine.base.OptionEngine SELECT 1
> 2014-03-27 15:11:14,324 INFO sqlalchemy.engine.base.OptionEngine ()
> 2014-03-27 15:11:14,324 INFO sqlalchemy.engine.base.OptionEngine COMMIT
>
>
...
> In your case, you should use a simple MySQL-python script first, get the
> SP to run and commit, without any “out of sync” messages. I think that is
> the actual problem you’re having.
>
>
>
A "SELECT @@AUTOCOMMIT" had the same result. However, the same query using
the standard library, along with a call to autocommit(), worked exactly as
expected. I should've mentioned that I'm calling into Amazon [RDS].
Let:
query = 'SELECT @@AUTOCOMMIT'
dsn = '<DSN string>'
SQLAlchemy code:
def alchemy_test():
e = create_engine(dsn, echo=True)
Session = sessionmaker()
Session.configure(bind=e)
session = Session()
r = session.execute(text(query, autocommit=True))
print(list(r))
Result:
2014-03-27 17:47:16,215 INFO sqlalchemy.engine.base.Engine SELECT DATABASE()
2014-03-27 17:47:16,215 INFO sqlalchemy.engine.base.Engine ()
2014-03-27 17:47:16,548 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES
LIKE 'character_set%%'
2014-03-27 17:47:16,548 INFO sqlalchemy.engine.base.Engine ()
2014-03-27 17:47:16,604 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES
LIKE 'sql_mode'
2014-03-27 17:47:16,604 INFO sqlalchemy.engine.base.Engine ()
2014-03-27 17:47:16,670 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2014-03-27 17:47:16,670 INFO sqlalchemy.engine.base.Engine SELECT
@@AUTOCOMMIT
2014-03-27 17:47:16,670 INFO sqlalchemy.engine.base.Engine ()
[(0L,)]
Direct example:
def direct_test():
import MySQLdb
conn = MySQLdb.connect(host='db.host.com', user='abc', passwd="def",
db="ghi", port=3307)
conn.autocommit(True)
c = conn.cursor()
c.execute(query)
print(c.fetchone())
Result:
(1L,)
Any idea why SA is falling down on this?
Dustin
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.