Re: [sqlalchemy] More efficient Insert mechanism

2010-02-02 Thread Mati Skiva
Michael Bayer wrote: matiskiva wrote: Naturally, the problem is that SA collects the generated id, that is why every statement is executed alone, and than the generated id is retrieved. I was wondering though, is there some kind of a more efficient mechanism? At least on MySQL, under

Re: [sqlalchemy] UserDefinedType and result_processor

2010-02-02 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 1, 2010, at 8:31 PM, Manlio Perillo wrote: Hi. I have defined a custom type for PostgreSQL ltree support. [...] This works, when I create the table and insert some values. However when I select data from

[sqlalchemy] session commit and the GIL

2010-02-02 Thread Eyal Gordon
Hello, I'm running sqlalchemy on python 2.4.3, with postgresql. My application is multi-threaded, commits and queries are protected by a python thread lock. I suspect that when running session.commit(), the python global interpreter lock (GIL) remains owned by this thread until the commit

[sqlalchemy] Re: Access property in query.

2010-02-02 Thread Andy
Thanks, that worked like a charm. Look forward to your PyCon presentation. On Feb 2, 12:56 am, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 1, 2010, at 9:24 PM, Andy (Zenom) wrote: I don't know if my terminology is correct etc. But the basic idea is the following. In my model

Re: [sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-02 Thread Michael Bayer
avdd wrote: On Feb 2, 2:52 am, Michael Bayer mike...@zzzcomputing.com wrote: the behavior you first illustrated, that of merge() and add() not acting the same regarding pending changes, was a behavior that was somewhat in the realm of a bug.   I mentioned the other day it was fixed in r6711.  

Re: [sqlalchemy] session commit and the GIL

2010-02-02 Thread Antoine Pitrou
Le mardi 02 février 2010 à 01:08 -0800, Eyal Gordon a écrit : Hello, I'm running sqlalchemy on python 2.4.3, with postgresql. My application is multi-threaded, commits and queries are protected by a python thread lock. I suspect that when running session.commit(), the python global

Re: [sqlalchemy] More efficient Insert mechanism

2010-02-02 Thread Michael Bayer
Mati Skiva wrote: Thank you for your feedback. In the case I mentioned, I cannot just dump the 30K items. Because I need their generated id's for other inserted rows (I have relations) In more detail, I am inserting resource items, and also mission items, each mission connects to a resource

Re: [sqlalchemy] session commit and the GIL

2010-02-02 Thread Michael Bayer
Eyal Gordon wrote: Hello, I'm running sqlalchemy on python 2.4.3, with postgresql. My application is multi-threaded, commits and queries are protected by a python thread lock. I suspect that when running session.commit(), the python global interpreter lock (GIL) remains owned by this thread

[sqlalchemy] Re: Access property in query.

2010-02-02 Thread Andy (Zenom)
The one thing that is frustrating is it is re-querying the database. So if I create a simple server side function how would I do that? I am currently using trunk. On Feb 2, 8:57 am, Andy andy.hol...@belator.com wrote: Thanks, that worked like a charm. Look forward to your PyCon presentation.

Re: [sqlalchemy] Re: Access property in query.

2010-02-02 Thread Michael Bayer
Andy (Zenom) wrote: The one thing that is frustrating is it is re-querying the database. So if I create a simple server side function how would I do that? I am currently using trunk. how to create the server side function or how to use it from SQLA ? the column_property() thing is where you'd

[sqlalchemy] Re: Access property in query.

2010-02-02 Thread Andy (Zenom)
I got the server side one created in schema cms, function name is slugify. I am trying to figure out how to let sqlalchemy know about the function and the schema its in. On postgresql I can do like SELECT cms.slugify(title) FROM cms.tablename, and it returns the slugified title, but to get that

Re: [sqlalchemy] Re: Access property in query.

2010-02-02 Thread Michael Bayer
Andy (Zenom) wrote: I got the server side one created in schema cms, function name is slugify. I am trying to figure out how to let sqlalchemy know about the function and the schema its in. On postgresql I can do like SELECT cms.slugify(title) FROM cms.tablename, and it returns the

[sqlalchemy] Re: Access property in query.

2010-02-02 Thread Andy (Zenom)
I do this, and the query it spits out in the error works fine in the postgresql command line, but not in sqlalchemy. Traceback: http://pylonshq.com/tracebacks/9b322f31095beda23f5d846e43399d21 query: 'SELECT DISTINCT cms.niches.title AS cms_niches_title, cms.niches.niche_id AS

[sqlalchemy] Re: Access property in query.

2010-02-02 Thread Andy (Zenom)
Scratch the last, helps if I have my development.ini pointed to the proper database server :) Its working fine. Thanks for all the help :) On Feb 2, 11:24 am, Andy (Zenom) stress...@gmail.com wrote: I do this, and the query it spits out in the error works fine in the postgresql command line,

Re: [sqlalchemy] Mixing matching connectors and dialects in 0.6

2010-02-02 Thread Bo Shi
Hi Michael, Thanks for the tip on dialect creation; I have a working connection and much of the low level library functionality appears to just work. I've just started digging into the internals to begin implementing introspection support. One issue I've encountered is that PyODBC happens to

Re: [sqlalchemy] More efficient Insert mechanism

2010-02-02 Thread Michael Bayer
Mati Skiva wrote: I believe I took these issues into account. But just to be sure, maybe you can highlight something for me. I assume the followings about the process of session.add: * after session.add is called, the objects are placed in a to-do pool (maybe) * for self-generating-id

[sqlalchemy] relations and multiple declarative bases

2010-02-02 Thread Chris Withers
Hi All, The script at the end of this message blows up with: sqlalchemy.exc.InvalidRequestError: When compiling mapper Mapper|Employee|employee, expression 'Organisation' failed to locate a name (name 'Organisation' is not defined). If this is a class name, consider adding this relation() to

Re: [sqlalchemy] any way to pre cook a monster query?

2010-02-02 Thread Chris Withers
Michael Bayer wrote: Piecing together a select() construct and compiling to a string is a relatively inexpensive operation.The vast majority of time in Query is spent about 1/3rd-half on the database side and the rest in fetching rows and instantiating/populating objects. Fair enough.

[sqlalchemy] insert with scalar select statament

2010-02-02 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I have written a small class in order to support PostgreSQL tsearch type: class TextSearchVector(UserDefinedType): Support for full-text search See http://www.postgresql.org/docs/8.4/static/datatype-textsearch.html def

Re: [sqlalchemy] relations and multiple declarative bases

2010-02-02 Thread Michael Bayer
Chris Withers wrote: Hi All, The script at the end of this message blows up with: sqlalchemy.exc.InvalidRequestError: When compiling mapper Mapper|Employee|employee, expression 'Organisation' failed to locate a name (name 'Organisation' is not defined). If this is a class name, consider

Re: [sqlalchemy] More efficient Insert mechanism

2010-02-02 Thread Mati Skiva
Michael Bayer wrote: Mati Skiva wrote: I believe I took these issues into account. But just to be sure, maybe you can highlight something for me. I assume the followings about the process of session.add: * after session.add is called, the objects are placed in a to-do pool (maybe) * for

Re: [sqlalchemy] insert with scalar select statament

2010-02-02 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I have written a small class in order to support PostgreSQL tsearch type: class TextSearchVector(UserDefinedType): Support for full-text search See

[sqlalchemy] engine.execute() vs text().execute()

2010-02-02 Thread Douglas Alan
Hi. I'm trying to track down a problem, and I'm wondering if the following two statements are appreciably different? I would have thought they were equivalent: (1) result = engine.execute(myQuery) (2) result = text(myQuery, engine).execute() myQuery is a string containing a big, hairy SQL

Re: [sqlalchemy] More efficient Insert mechanism

2010-02-02 Thread Michael Bayer
Mati Skiva wrote: from inspecting mapper.py's _save_obj method, I found that after every insert the following items are required: * value_params - used by _postfetch * params - used by _postfetch * ResultProxy.last_inserted_params() - used by _postfetch *

Re: [sqlalchemy] insert with scalar select statament

2010-02-02 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] In SQL (tested with PostgreSQL and SQLite, at least) I can do: INSERT INTO test (text) values(to_tsvector('some text')); That is, it is possible to specify a scalar select statement for each value. Is this

Re: [sqlalchemy] insert with scalar select statament

2010-02-02 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] In SQL (tested with PostgreSQL and SQLite, at least) I can do: INSERT INTO test (text) values(to_tsvector('some text')); That is, it is possible to specify a scalar select statement for

Re: [sqlalchemy] insert with scalar select statament

2010-02-02 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: Manlio Perillo wrote: [...] OK you mean SQL expression during compilation. This is ticket #1534 which is not yet implemented. After some tests I got something that works http://paste.pocoo.org/show/173099/ [...]

Re: [sqlalchemy] insert with scalar select statament

2010-02-02 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: Manlio Perillo wrote: [...] OK you mean SQL expression during compilation. This is ticket #1534 which is not yet implemented. After some tests I got something that works

Re: [sqlalchemy] passive updates and concurrent mod error

2010-02-02 Thread Michael Bayer
avdd wrote: Something a bit more normal now. Combining optimistic concurrency control with cascading PK updates is problematic, if you load the child relation, the session issues unecessary updates for the children, resulting in ConcurrentModificationError this issue is fixed in trunk as