Re: [sqlalchemy] how to use version_id_col

2011-01-18 Thread Jan Mueller
On 01/18/2011 02:08 AM, Michael Bayer wrote: On Jan 17, 2011, at 5:42 PM, Jan Mueller wrote: try: obj = Session.query(MyObject).filter(MyObject.updated_at == my_hidden_updated_at).filter(MyObject.id == id).one() except orm.exc.NoResultFound:

[sqlalchemy] Re: rollback not working

2011-01-18 Thread bool
I have put a self contained script that can probably reproduce this for you. I think that the argument 'connect_args': {'autocommit' : True } is causing the transactions to not work properly. Is this expected and if so can you explain the reason. Thanks in advance.

[sqlalchemy] class_variable as polymorphic_identity

2011-01-18 Thread Erkan Özgür Yılmaz
Hi everybody, (fast start :) ) I have a class hierarchy and I'm using joined table inheritance, but my classes are not always going to be used with SQLAlchemy (or I plan to give the freedom to people to use these classes anywhere they want). Anyway I was using the entity_type column in my base

[sqlalchemy] Joining three tables - Selecting column from two different tables

2011-01-18 Thread Steve
Hi all, Newbie here. I just want to execute the following sql using SqlAlchemy . But getting various errors. select ssf.factor,ssf.displayname,pmw.weight from probability_models_weights pmw inner join probability_models pm on pm.id = pmw.model_id inner join success_factors ssf on ssf.id =

Re: [sqlalchemy] Re: rollback not working

2011-01-18 Thread Michael Bayer
that is absolutely the reason transactions would not be working for you. autocommit on the DBAPI essentially makes the commit() and rollback() methods of the DBAPI connection a no-op. On Jan 18, 2011, at 5:12 AM, bool wrote: I have put a self contained script that can probably reproduce

Re: [sqlalchemy] Joining three tables - Selecting column from two different tables

2011-01-18 Thread Michael Bayer
On Jan 18, 2011, at 9:11 AM, Steve wrote: Hi all, Newbie here. I just want to execute the following sql using SqlAlchemy . But getting various errors. select ssf.factor,ssf.displayname,pmw.weight from probability_models_weights pmw inner join probability_models pm on pm.id =

Re: [sqlalchemy] class_variable as polymorphic_identity

2011-01-18 Thread Michael Bayer
On Jan 18, 2011, at 9:42 AM, Erkan Özgür Yılmaz wrote: Hi everybody, (fast start :) ) I have a class hierarchy and I'm using joined table inheritance, but my classes are not always going to be used with SQLAlchemy (or I plan to give the freedom to people to use these classes anywhere

[sqlalchemy] Problem with a query

2011-01-18 Thread Alvaro Reinoso
Hi all, It doesn't do the second filter with those queries: session.query(User).options(joinedload(channels)).filter(User.id == int(userId)).filter(Channel.title != zeptextstuff.txt).order_by(Channel.titleView).first() or session.query(User).join(User.channels).filter(User.id ==

Re: [sqlalchemy] Problem with a query

2011-01-18 Thread Michael Bayer
you want to use query.join() here, not joinedload. http://www.sqlalchemy.org/trac/wiki/FAQ#ImusinglazyFalsetocreateaJOINOUTERJOINandSQLAlchemyisnotconstructingthequerywhenItrytoaddaWHEREORDERBYLIMITetc.whichreliesupontheOUTERJOIN I need to update the links in that FAQ entry. On Jan 18, 2011,

[sqlalchemy] DB API for MSSQL on Cygwin

2011-01-18 Thread dclist
Has anyone had success with installing a DB API for Microsoft SQL Server on Cygwin? I could not install pyodbc or pymssql on Cygwin, ostensibly due to a lack of support for Cygwin and there isn't a specific Cygwin compatibility column on

[sqlalchemy] Writing values to Postgresql type Float

2011-01-18 Thread wilbur
Hello, I am having problems using sqlalchemy to write values to Postgresq columns of type Float. I am getting sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt errors when I try to insert records. My Postgresql table is defined as: Column | Type |

[sqlalchemy] I need a final push

2011-01-18 Thread F.A.Pinkse
Hi All, I need a last pushand I hope someone here in SQLAlcheny cab give me some. My application uses elixir on a sqlite database. I Have a table Person with a field birthdate, now I want to sort on the month of this field. From examples and a lot of peeking I have worked out how to

[sqlalchemy] reflected DATETIME

2011-01-18 Thread Catherine Devlin
I'm trying to build a MySQL-PostgreSQL migration tool that reflects tables from MySQL, then creates them in pg. So far so good, except that when SQLAlchemy reflects a MySQL table with a DATETIME column, it reflects it as a sqlalchemy.types.DATETIME, then tries to create a DATETIME in PostgreSQL.

[sqlalchemy] INSERT RETURNING question

2011-01-18 Thread Eric Lemoine
Hi Probably a very simple question. I use the ORM for inserts, with postgres 8.3. How can I get the ids resulting from my inserts' RETURNING clauses? I haven't been able to find the information in the doc. Thanks a lot, -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le

[sqlalchemy] Re: INSERT RETURNING question

2011-01-18 Thread Eric Lemoine
On Tuesday, January 18, 2011, Eric Lemoine eric.lemo...@camptocamp.com wrote: Hi Probably a very simple question. I use the ORM for inserts, with postgres 8.3. How can I get the ids resulting from my inserts' RETURNING clauses? I haven't been able to find the information in the doc. Doing

Re: [sqlalchemy] Re: INSERT RETURNING question

2011-01-18 Thread Michael Bayer
On Jan 18, 2011, at 4:47 PM, Eric Lemoine wrote: On Tuesday, January 18, 2011, Eric Lemoine eric.lemo...@camptocamp.com wrote: Hi Probably a very simple question. I use the ORM for inserts, with postgres 8.3. How can I get the ids resulting from my inserts' RETURNING clauses? I haven't

Re: [sqlalchemy] Re: INSERT RETURNING question

2011-01-18 Thread Jan Mueller
On 01/18/2011 10:47 PM, Eric Lemoine wrote: On Tuesday, January 18, 2011, Eric Lemoineeric.lemo...@camptocamp.com wrote: Hi Probably a very simple question. I use the ORM for inserts, with postgres 8.3. How can I get the ids resulting from my inserts' RETURNING clauses? I haven't been able to

Re: [sqlalchemy] reflected DATETIME

2011-01-18 Thread Michael Bayer
Ultimately you have to modify the reflected tables or rewrite them using data types that are appropriate to the target database. Reflection is in fact going to produce the most specific type possible, so in this case you're actually getting sqlalchemy.dialects.mysql.VARCHAR objects and such

Re: [sqlalchemy] I need a final push

2011-01-18 Thread Michael Bayer
On Jan 18, 2011, at 3:48 PM, F.A.Pinkse wrote: Hi All, I need a last pushand I hope someone here in SQLAlcheny cab give me some. My application uses elixir on a sqlite database. I Have a table Person with a field birthdate, now I want to sort on the month of this field. From

Re: [sqlalchemy] Writing values to Postgresql type Float

2011-01-18 Thread Michael Bayer
Here's a tested example of DOUBLE_PRECISION using both float and Decimal versions. Make sure you're on a recent release of psycopg2: from sqlalchemy import Column, create_engine, Integer from sqlalchemy.orm import Session from sqlalchemy.ext.declarative import declarative_base from

Re: [sqlalchemy] class_variable as polymorphic_identity

2011-01-18 Thread Erkan Özgür Yılmaz
thanks Michael, because I edited my question a couple of times, and also trying to solve it while editing the text, it went to a slightly different way then I want to point to, Let me explain it in a different way, may be I am asking the wrong question: Right now I'm developing an Open Source

[sqlalchemy] ODBC general question

2011-01-18 Thread Warwick Prince
Hi All We need to connect to a Progress database, and we are in the very early days of this. I understand it supports an ODBC interface and therefore should be able to be connected to using SA - correct? Are there any limitations on the ODBC connector or gotcha's that we should look out for?

Re: [sqlalchemy] class_variable as polymorphic_identity

2011-01-18 Thread Michael Bayer
On Jan 18, 2011, at 6:51 PM, Erkan Özgür Yılmaz wrote: thanks Michael, because I edited my question a couple of times, and also trying to solve it while editing the text, it went to a slightly different way then I want to point to, Let me explain it in a different way, may be I am

Re: [sqlalchemy] ODBC general question

2011-01-18 Thread Michael Bayer
pyodbc works very well, as does mxodbc which is commercial. Most issues have to do with using ODBC from unix, where if we're working for free we use FreeTDS, that has a lot of quirks. There are commercial ODBC drivers for unix which I haven't used but we will be using them soon for a

Re: [sqlalchemy] ODBC general question

2011-01-18 Thread Warwick Prince
Hi Michael Thanks yet again for excellent advice provided in a timely manner! :-) Cheers Warwick On 19/01/2011, at 10:25 AM, Michael Bayer wrote: pyodbc works very well, as does mxodbc which is commercial. Most issues have to do with using ODBC from unix, where if we're working for free

[sqlalchemy] Adjacency List Relationship in a Child Class

2011-01-18 Thread Michael Naber
Whenever I try to establish an adjacency list relationship within a child class (Department -- Parent Department in this case) the orm complains about foreign key columns present in both the parent and child class, and won’t construct the mapping. Below is an example illustrating the problem. I'd

Re: [sqlalchemy] Re: INSERT RETURNING question

2011-01-18 Thread Eric Lemoine
On Tue, Jan 18, 2011 at 11:33 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 18, 2011, at 4:47 PM, Eric Lemoine wrote: On Tuesday, January 18, 2011, Eric Lemoine eric.lemo...@camptocamp.com wrote: Hi Probably a very simple question. I use the ORM for inserts, with postgres 8.3.