[sqlalchemy] Speed matters

2011-06-01 Thread Fabien Ribes
Hi, I have three tables (user, identifiers, groups) with 'many to one' and 'many to many' relationships. My code for deleting a user works correctly but I would like to have it run faster. What improvements do you suggest ? code def delete_list(self, user_ids): Delete a list of users

Re: [sqlalchemy] Exclusive SELECT?

2011-06-01 Thread A.M.
On Jun 1, 2011, at 12:56 AM, thatsanicehatyouh...@mac.com wrote: Hi, I'm working on a script using SQLAlchemy against a PostgreSQL database and using Python's multiprocessing. The pattern is for each thread to: - start a transaction (session.begin()) - retrieve the next row in table X

[sqlalchemy] logging user changes

2011-06-01 Thread Sebastian Elsner
Hello, I want to introduce logging to my SA application, so the users with elevated privileges can control what normal users change in the database. The log should go to the database not to a file. I have been thinking about a logger table like: table action: - column: datetime_of_action

Re: [sqlalchemy] Exclusive SELECT?

2011-06-01 Thread thatsanicehatyouhave
Hi M, Thanks very much for your help. Adding .with_lockmode('update') to my session.query statement worked like a charm! Now I just need to figure out how to catch exceptions that occur in the work unit in the thread, but that's a topic for another list... Cheers, Demitri -- You received

[sqlalchemy] custom Python functions as part of SQL queries

2011-06-01 Thread Tom Kralidis
Hi, I'm using SQLAlchemy 0.6.6 for a web application. At this point, the app uses SQLite3 as the underlying database; I'm currently working on abstracting this out to work with others (PostgreSQL, MySQL). At a high level, the application receives CGI queries which are parsed and sent to

Re: [sqlalchemy] custom Python functions as part of SQL queries

2011-06-01 Thread Michael Bayer
As discussed on IRC, for those reading the list, the difference here is between SQLite's ability to embed native functions (and in turn Pysqlite's ability to use Python functions in this way), and other databases that don't run as embedded libraries. The functions need to be expressed as

[sqlalchemy] begin_nested failures starting with 0.7

2011-06-01 Thread Jon Nelson
I've got a chunk of code that started failed as soon as I started testing with 0.7. The failure is: sqlalchemy.exc.StatementError: This Connection is closed '\nCREATE TABLE bar (\n\ta TEXT NOT NULL\n)\n\n' None I'll note that the logging indicates that the connection was returned to the pool

Re: [sqlalchemy] begin_nested failures starting with 0.7

2011-06-01 Thread Michael Bayer
metadata.reflect() would close() the connection used for reflection as it assumed it was passed an Engine, not a Connection, fixed in r926ee70b67ff. Nothing to do with begin_nested() or anything like that. On Jun 1, 2011, at 5:10 PM, Jon Nelson wrote: I've got a chunk of code that

Re: [sqlalchemy] begin_nested failures starting with 0.7

2011-06-01 Thread Jon Nelson
On Wed, Jun 1, 2011 at 4:47 PM, Michael Bayer mike...@zzzcomputing.com wrote: metadata.reflect() would close() the connection used for reflection as it assumed it was passed an Engine, not a Connection, fixed in r926ee70b67ff.   Nothing to do with begin_nested() or anything like that. Why

Re: [sqlalchemy] begin_nested failures starting with 0.7

2011-06-01 Thread Jon Nelson
On Wed, Jun 1, 2011 at 6:00 PM, Jon Nelson jnel...@jamponi.net wrote: On Wed, Jun 1, 2011 at 4:47 PM, Michael Bayer mike...@zzzcomputing.com wrote: metadata.reflect() would close() the connection used for reflection as it assumed it was passed an Engine, not a Connection, fixed in

Re: [sqlalchemy] begin_nested failures starting with 0.7

2011-06-01 Thread Michael Bayer
On Jun 1, 2011, at 7:00 PM, Jon Nelson wrote: On Wed, Jun 1, 2011 at 4:47 PM, Michael Bayer mike...@zzzcomputing.com wrote: metadata.reflect() would close() the connection used for reflection as it assumed it was passed an Engine, not a Connection, fixed in r926ee70b67ff. Nothing to do

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

2011-06-01 Thread Randy Syring
I'd like to be able to dump an MS SQL server's objects to text on the local file system. I have a working solution for views, stored procedures, and functions, but tables are a different story. Can i use SA's reflection and table creation abilities to write create table DDL to a text file? --

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

2011-06-01 Thread Randy Syring
In the FAQ...sorry: http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring On Jun 1, 8:01 pm, Randy Syring ra...@rcs-comp.com wrote: I'd like to be able to dump an MS SQL server's objects to text on the local file system.  I have a working solution for views,

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

2011-06-01 Thread Michael Bayer
sure, you'd use the mock executor as in the second example here: http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring On Jun 1, 2011, at 8:01 PM, Randy Syring wrote: I'd like to be able to dump an MS SQL server's objects to text on the local file system.

[sqlalchemy] Re: Speed matters

2011-06-01 Thread Sergey V.
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 is not necessary too I think. code session.query(Identifier).filter(Identifier.user_id.in_(user_ids)).delete()