[sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-02 Thread Randy Syring
Looks like I beat you to the answer by about 3 mins, thanks for answering though. :) I have a follow-up though. The foreign key constraints are not getting created with ON DELETE CASCADE as expected. I tried this in both MSSQL and Postgres. Is this expected behavior? If so, is it possible to

[sqlalchemy] Re: Multi-Processing Environment

2011-06-02 Thread ddarko
I use PostgreSQL, but it does not matter, because when someone changes the configuration it has still work. a new Engine needs to be created in each child fork If a worker can perform at any given time only one synchronous request and for each worker I create a new engine, it does not have any

Re: [sqlalchemy] Re: Speed matters

2011-06-02 Thread fribes
Hi Sergey, I'll give it a try, thanks ! On 2 June 2011 03:15, Sergey V. sergey.volob...@gmail.com wrote: Hi, One easy/obvious improvement would be to delete all user's identifiers and groups at once without iterating over them for every user. Actually, iterating over the list of user_ids

[sqlalchemy] Sqlalchemy exception for mysql in window: TypeError: immutabledict object is immutable

2011-06-02 Thread zhwolf
Hi, I experienced the exception while accessing a mysql database in windows via sqlalchemy0.7.0. It should be due to source code error in 0.7.0: The member tables of class MetaData is created as immutabledict, sqlalchemy\schema.py::line 2181 self.tables = util.immutabledict() But the

[sqlalchemy] Long running transaction issues with commit

2011-06-02 Thread Aalok Sood
Hello Everyone My mysql server wait_timeout is set to 35. and if i run this code: # Session s made with autocommit=False mm=s.query(ss.Machine).get(1) In [9]: In [10]: for i in range(1000): : sleep(15) : print commiting : s.commit() : sleep(25)

Re: [sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-02 Thread Michael Bayer
On Jun 2, 2011, at 3:14 AM, Randy Syring wrote: Looks like I beat you to the answer by about 3 mins, thanks for answering though. :) I have a follow-up though. The foreign key constraints are not getting created with ON DELETE CASCADE as expected. I tried this in both MSSQL and

Re: [sqlalchemy] Sqlalchemy exception for mysql in window: TypeError: immutabledict object is immutable

2011-06-02 Thread Michael Bayer
This is a bug (you've just discovered it, thanks !). I've added ticket #2181 for this and I'm hoping to do a pass for 0.7.1 this weekend. The issue is specific to windows and MySQL (not a platform we get as much opportunity to test on...). I would be curious, if you are naming the table

Re: [sqlalchemy] Long running transaction issues with commit

2011-06-02 Thread Michael Bayer
The Session doesn't interact with the database until statements are first emitted, so while its being put into a new transaction each time with your block of code, probably nothing is being sent to the DB. If you stuck a line: s.execute(select 1) in there, that would likely wake it up. On

[sqlalchemy] Re: Long running transaction issues with commit

2011-06-02 Thread Aalok Sood
Hello Michael Thanks a lot for your quick response. I changed this loop to: or i in range(1000): : sleep(15) : print commiting : mm.name=u'old name' : s.commit() : sleep(25) : mm.name=u'new name' : print commiting2

Re: [sqlalchemy] Re: Long running transaction issues with commit

2011-06-02 Thread Michael Bayer
On Jun 2, 2011, at 11:35 AM, Aalok Sood wrote: Hello Michael Thanks a lot for your quick response. I changed this loop to: or i in range(1000): : sleep(15) : print commiting : mm.name=u'old name' : s.commit() : sleep(25) :

[sqlalchemy] Re: Long running transaction issues with commit

2011-06-02 Thread Aalok Sood
Yes its all so very clear now, kind of obvious :) Thank you for taking out time to help me. Regards Aalok Sood. On Jun 2, 9:20 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 2, 2011, at 11:35 AM, Aalok Sood wrote: Hello Michael Thanks a lot for your quick response. I

[sqlalchemy] TRUNCATE sql statement

2011-06-02 Thread RVince
I am trying to issue a straight SQL TRUNCATE table command: engine = engine_from_config(config, 'sqlalchemy.') connection = engine.connect() connection.execute('truncate table cms_history;') Everything runs fine without error -- but the table does not truncate -- nothing is affected. Am I

[sqlalchemy] Re: TRUNCATE sql statement

2011-06-02 Thread RVince
I found the answer. I needs to be wrapped in a transaction, like this: engine = engine_from_config(config, 'sqlalchemy.') connection = engine.connect() trans = connection.begin() try: connection.execute('truncate table cms_history;')

Re: [sqlalchemy] Re: TRUNCATE sql statement

2011-06-02 Thread Michael Bayer
not to answer every question today, but we also added an autocommit flag for this kind of thing: connection.execution_options(autocommit=True).execute(statement that normally isn't autocommit) some background: http://www.sqlalchemy.org/docs/core/connections.html#understanding-autocommit On

[sqlalchemy] Dynamic relationship

2011-06-02 Thread Ben Chess
Hi, I want to establish a relationship with an object whose key is defined inside a JSON BLOB column in the child. Naively, I know I can do this via a regular python @property that uses object_session() to then do a query() using the id from inside the blob. Is there a better way that lets

Re: [sqlalchemy] Dynamic relationship

2011-06-02 Thread Michael Bayer
Using a BLOB as a key is a really bad idea and wont work on all backends, but other than the database-level limitations inherent, SQLAlchemy will let you set up whatever column you'd like to use as the key just fine within a relationship(). Guessing what the problem might be. Foreign key ?

Re: [sqlalchemy] Dynamic relationship

2011-06-02 Thread Ben Chess
I'm not intending for the contents of the BLOB to be readable to MySQL. It would only be cracked open and read from within Python. Meaning Python only knows what the key actually is. So yeah, I understand the caveats of this approach. I merely want to provide a mechanism to, as a second

Re: [sqlalchemy] Dynamic relationship

2011-06-02 Thread Ben Chess
On Thu, Jun 2, 2011 at 5:18 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 2, 2011, at 8:11 PM, Ben Chess wrote: I'm not intending for the contents of the BLOB to be readable to MySQL.  It would only be cracked open and read from within Python. Meaning Python only knows what the

Re: [sqlalchemy] Dynamic relationship

2011-06-02 Thread Michael Bayer
On Jun 2, 2011, at 8:25 PM, Ben Chess wrote: On Thu, Jun 2, 2011 at 5:18 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 2, 2011, at 8:11 PM, Ben Chess wrote: I'm not intending for the contents of the BLOB to be readable to MySQL. It would only be cracked open and read from

Re: [sqlalchemy] Dynamic relationship

2011-06-02 Thread Ben Chess
Sounds far more complicated than something I'd want to take on. Thanks for your thoughts and the detailed response. Ben On Thu, Jun 2, 2011 at 6:28 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 2, 2011, at 8:25 PM, Ben Chess wrote: On Thu, Jun 2, 2011 at 5:18 PM, Michael Bayer

[sqlalchemy] Re: Sqlalchemy exception for mysql in window: TypeError: immutabledict object is immutable

2011-06-02 Thread zhwolf
Thanks, the patch works now. Jun Zhou -- 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 sqlalchemy+unsubscr...@googlegroups.com. For

Re: [sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-02 Thread Randy Syring
That was it, thanks. I was trying to go through the column and looking at it's foreign_keys collection. When I set those values, it didn't affect the output. Reflects my ignorance of SA, obviously. Thanks again. -- Randy Syring Intelicom Direct: