Re: [sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Mike Lessings
It appears to be a consequence of having uncommitted / rollback'd InnoDB transactions. they don't show up in `show full processlist` so it's a hard thing to debug, especially if you don't have SUPER privileges. if I did, this: show innodb status; would probably show the outstanding ones. a

Re: [sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Michael Bayer
On Feb 16, 2014, at 8:37 PM, Mike Lessings wrote: > You are right, MySQL itself is doing something odd. However I feel like > SQLAlchemy must have done some funny locking that is causing the database to > act strangely, and I'd like to find out how and how to avoid that. SQLAlchemy doesn’t “

Re: [sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Mike Lessings
I even restarted the MySQL server, no effect and same problem. On Sunday, February 16, 2014 8:37:01 PM UTC-5, Mike Lessings wrote: > > You are right, MySQL itself is doing something odd. However I feel like > SQLAlchemy must have done some funny locking that is causing the database > to act stra

Re: [sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Mike Lessings
You are right, MySQL itself is doing something odd. However I feel like SQLAlchemy must have done some funny locking that is causing the database to act strangely, and I'd like to find out how and how to avoid that. Here's the output from the query with echo=True: SELECT object.id AS object_id

Re: [sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Michael Bayer
On Feb 16, 2014, at 7:50 PM, Mike Lessings wrote: > I'm trying to lock rows when I select because I intend to update them shortly > thereafter. I don't want another session in another process to simultaneously > be reading/updating. In code: > > # ... all necessary setup and Session creation

Re: [sqlalchemy] Re: Using sqlalchemy models with run-time connection

2014-02-16 Thread Alexander Perepelica
Aha, Base (declarative_base) don't need proper connection to db in any point. Connection with database must be established only when execute queries. Thank you very much! 2014-02-17 3:10 GMT+02:00 Michael Bayer : > > On Feb 16, 2014, at 7:28 PM, Alexander Perepelica < > perepelica.a...@gmail.com

Re: [sqlalchemy] Re: Using sqlalchemy models with run-time connection

2014-02-16 Thread Michael Bayer
On Feb 16, 2014, at 7:28 PM, Alexander Perepelica wrote: > Great, so I define in my code > > session = None > Base = declarative_base() > > class Model1(Base): > id = > > and after user input host IP we can execute code > > engine = create_engine(“postgresql+psycopg2://scott:tige

[sqlalchemy] locking rows for updates hangs indefinitely

2014-02-16 Thread Mike Lessings
I'm trying to lock rows when I select because I intend to update them shortly thereafter. I don't want another session in another process to simultaneously be reading/updating. In code: # ... all necessary setup and Session creation session = Session() with session.no_autoflush: session.beg

[sqlalchemy] Re: Using sqlalchemy models with run-time connection

2014-02-16 Thread Alexander Perepelica
Great, so I define in my code session = None Base = declarative_base() class Model1(Base): id = and after user input host IP we can execute code engine = create_engine(“postgresql+psycopg2://scott:tiger@somehostname/test”, poolclass=NullPool) session = sessionmaker(bind=engine)

Re: [sqlalchemy] Using sqlalchemy models with run-time connection

2014-02-16 Thread Michael Bayer
On Feb 16, 2014, at 7:05 PM, Alexander Perepelica wrote: > Ok, I understand, but how can I bind model with this session? Must I use > declarative_base or mapping approach? the concept of “the thing that talks to a database” and “the kinds of structures that write SQL for us” are separate.

[sqlalchemy] Re: Using sqlalchemy models with run-time connection

2014-02-16 Thread Alexander Perepelica
Ok, I understand, but how can I bind model with this session? Must I use declarative_base or mapping approach? -- 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 sq

Re: [sqlalchemy] Using sqlalchemy models with run-time connection

2014-02-16 Thread Michael Bayer
On Feb 16, 2014, at 6:09 PM, Alexander Perepelica wrote: > Hello! > > I use sqlalchemy in flask app and try create some database editor. > And my problem is using sqlalchemy models and give to user possibility change > IP address of database server (or connect to server at runtime). > Can I

[sqlalchemy] Using sqlalchemy models with run-time connection

2014-02-16 Thread Alexander Perepelica
Hello! I use sqlalchemy in flask app and try create some database editor. And my problem is using sqlalchemy models and give to user possibility change IP address of database server (or connect to server at runtime). Can I do such things with sqlalchemy? Thank you! -- You received this messag

Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-16 Thread Jay Pipes
On Sun, 2014-02-16 at 12:17 -0500, Michael Bayer wrote: > > On Feb 15, 2014, at 11:38 PM, Jay Pipes wrote: > > > Thank you Michael. Yes, that is indeed the case if I delete an > > object via session.delete(). > > > > Unfortunately, it seems that if I execute the DELETE manually > > against the

Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-16 Thread Michael Bayer
On Feb 15, 2014, at 11:38 PM, Jay Pipes wrote: > Thank you Michael. Yes, that is indeed the case if I delete an object via > session.delete(). > > Unfortunately, it seems that if I execute the DELETE manually against the > table in question, that the delete does not cascade, as shown by this

Re: [sqlalchemy] How can I declare the 'row_format' and 'key_block_size' during table creation?

2014-02-16 Thread DoDo
Thank you very much for your reply. now, I find how to set these parameter correctly. So I place these parameter in __table_args__ and it works! __table_args__ = {'mysql_charset': 'utf8', 'mysql_engine': 'InnoDB', 'mysql_collate': 'utf8_general_ci', 'mysql_row_format': 'COM