[sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread rpkelly
It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy can convert the values to literal binds. Which, in the example given, isn't the case. -- You received this message because you are subscribed to the

[sqlalchemy] How to do a query on a returned object?

2014-06-18 Thread Bao Niu
I have a Person class and a Names class, which have a one-to-many relationship ( a person can have many names ). After doing a query like this: p = session.query(Person).filter(Person.birthday 1992-01-01).one() I'd like to further perform a query on the returned object p to select only its

Re: [sqlalchemy] How to do a query on a returned object?

2014-06-18 Thread Simon King
On Wed, Jun 18, 2014 at 8:40 AM, Bao Niu niuba...@gmail.com wrote: I have a Person class and a Names class, which have a one-to-many relationship ( a person can have many names ). After doing a query like this: p = session.query(Person).filter(Person.birthday 1992-01-01).one() I'd like

Re: [sqlalchemy] How to do a query on a returned object?

2014-06-18 Thread Bao Niu
Thank you very much Simon! I skipped those parts without realizing how useful they are. Thanks a lot for point me the right direction! On Wed, Jun 18, 2014 at 3:57 AM, Simon King si...@simonking.org.uk wrote: On Wed, Jun 18, 2014 at 8:40 AM, Bao Niu niuba...@gmail.com wrote: I have a Person

Re: [sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread Mike Bayer
On 6/18/14, 2:06 AM, rpkelly wrote: It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy can convert the values to literal binds. Which, in the example given, isn't the case. the long standing practice for

Re: [sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread Ryan Kelly
On Wed, Jun 18, 2014 at 11:15 AM, Mike Bayer mike...@zzzcomputing.com wrote: On 6/18/14, 2:06 AM, rpkelly wrote: It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy can convert the values to literal binds.

Re: [sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread Mike Bayer
On 6/18/14, 12:03 PM, Ryan Kelly wrote: On Wed, Jun 18, 2014 at 11:15 AM, Mike Bayer mike...@zzzcomputing.com wrote: On 6/18/14, 2:06 AM, rpkelly wrote: It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy

[sqlalchemy] Functions on column properties

2014-06-18 Thread Mike Solomon
Hey all, First and foremost, thank you for this wonderful library! This is my first post to the list and I am very grateful for those who have taken the time to make sqlalchemy. I am using SQLalchemy as a backend for an object-oriented language I am developing. The way it works is that it

Re: [sqlalchemy] Functions on column properties

2014-06-18 Thread Mike Solomon
Le mercredi 18 juin 2014 22:03:33 UTC+3, Michael Bayer a écrit : if you can show the SQL you expect that would help. it seems in your SO question you want a subquery, you'd have to define that: class Holder(..): some_prop = column_property(select([func.max(1 * col1 / col2)]))

Re: [sqlalchemy] Functions on column properties

2014-06-18 Thread Mike Bayer
On 6/18/14, 4:50 PM, Mike Solomon wrote: Le mercredi 18 juin 2014 22:03:33 UTC+3, Michael Bayer a écrit : if you can show the SQL you expect that would help. it seems in your SO question you want a subquery, you'd have to define that: class Holder(..): some_prop =

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
Bumping this, is there a way to do a replacement with_polymorphic instead of an addition? Michael On Tuesday, April 8, 2014 3:59:34 PM UTC-4, Michael Weylandt wrote: On Monday, April 7, 2014 5:11:48 PM UTC-4, Michael Bayer wrote: On Apr 7, 2014, at 2:46 PM, Michael Weylandt

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
My use case is a simple CRUD app which has a history table (patterned on the example in the SQLAlchemy docs) and a current table. I want to write a simple context manager so that f = db.session.query(Foo).all() gives current values while: with app.as_of(date(2014, 05, 31)): f =

[sqlalchemy] How to have SQL IF in sqlalchemy

2014-06-18 Thread Vineet Goel
Hi, I am trying to convert the following SQL to SQLAlchemy: SELECT teams.department, teams.team, IF(employee_managers.team_id IS NOT NULL, employee_managers.manager, teams.default_manager) AS manager FROM teams LEFT JOIN employee_managers ON employee_managers.team_id = teams.id WHERE

[sqlalchemy] Re: How to have SQL IF in sqlalchemy

2014-06-18 Thread Michael Weylandt
Look at sqlalchemy.sql.func: http://docs.sqlalchemy.org/en/rel_0_9/core/functions.html On Wednesday, June 18, 2014 8:31:04 PM UTC-4, Vineet Goel wrote: Hi, I am trying to convert the following SQL to SQLAlchemy: SELECT teams.department, teams.team, IF(employee_managers.team_id IS

Re: [sqlalchemy] How to have SQL IF in sqlalchemy

2014-06-18 Thread Mike Bayer
On 6/18/14, 8:31 PM, Vineet Goel wrote: Hi, I am trying to convert the following SQL to SQLAlchemy: |SELECT teams.department, teams.team, IF(employee_managers.team_id IS NOT NULL, employee_managers.manager, teams.default_manager) AS manager FROM teams LEFT JOIN employee_managers