[sqlalchemy] Re: Testing Conditions for insertion, and grouping queries together

2007-08-28 Thread Michael Bayer
Mike Lewis wrote: Hi, I'm new to SQLAlchemy, and I was wondering if there's a way to test a condition while inserting. I'm trying to make my application use as few separate queries at the same time as possible. Here's a couple cases I have had issues with: Inserting something with a

[sqlalchemy] Re: One To Many Polymorphic Association.

2007-08-28 Thread Pradeep Jindal
On Monday 27 August 2007 19:57:21 Michael Bayer wrote: On Aug 24, 2007, at 8:39 AM, praddy wrote: ## from sqlalchemy import * meta = BoundMetaData('sqlite://', echo=False) # Parents table. parents = Table('parents', meta,

[sqlalchemy] Best way to handle in()

2007-08-28 Thread Kirk Strauser
I have mappers configured for main and child, and those tables are linked on main.childid=child.childid. How can I use in() to get rows where child.othercolumn is in a list of values? I'd like to do something like: foo = session.query(MainTable).filter_by(customer='CUSTNAME') foo =

[sqlalchemy] Re: Best way to handle in()

2007-08-28 Thread Paul Johnston
Hi, foo = session.query(MainTable).filter_by(customer='CUSTNAME') foo = foo.filter(ChildTable.c.othercolumn.in_('bar', 'baz', 'qux')) You need to do the join; pass the name of the relation (not the target table) to join: foo =

[sqlalchemy] Re: Generative group_by query specify columns

2007-08-28 Thread Curtis Scheer
So why is it possible do a query.group_by() but not a possible to specify the columns to select as execution of the query fails in postgresql because it is trying to select all the columns of table Foo in this instance. Or is their some way of combining the sql.select() module with the query

[sqlalchemy] Re: Best way to handle in()

2007-08-28 Thread sdobrev
sorry for my bad sql, but where have u specified that link? u should have something like foo.filter( (Main.chidlid==Child.childid) Child.othercolumn.in_('a', 'b', 'c') ) or foo.join( child).filter( Child.othercolumn.in_('a', 'b', 'c') ) (warning: the exact syntax may or may not be this,

[sqlalchemy] Re: Problem with tinyint(1) on mysql

2007-08-28 Thread jason kirtland
Mike Bernson wrote: Using SQLAlchemy version 0.4b4. When reflecting table from mysql database with tinyint(1) you get a boolean back. I think this is error because it returns a bad data type for tinyint(1). I have a database that work under 0.3.0 where to store a single digit I used