[sqlalchemy] Getting generic results from an ORM query?

2013-01-02 Thread John Anderson
I would like to generate this query: SELECT a.pk, aa.response FROM attendee as a JOIN field as f on f.conference_pk = a.conference_pk LEFT JOIN attendee_answer as aa ON aa.field_pk = f.pk AND aa.attendee_pk = a.pk; Using the ORM, I came up

[sqlalchemy] Array with custom types in SqlAlchemy 0.8b2

2013-01-02 Thread Michael van Tellingen
Hi all, I'm experimenting a bit with postgresql arrays of uuid's. Unfortunately I'm running into a bug or I'm not really understanding it :-) My schema definition is as follow: table = Table('example', metadata, Column('timestamp', DateTime(timezone=False), primary_key=True),

[sqlalchemy] Array with custom types in SqlAlchemy 0.8

2013-01-02 Thread Michael van Tellingen
Hi all, I'm experimenting a bit with postgresql arrays of uuid's. Unfortunately I'm running into a bug or I'm not really understanding it :-) My schema definition is as follow: table = Table('example', metadata, Column('timestamp', DateTime(timezone=False), primary_key=True),

Re: [sqlalchemy] Getting generic results from an ORM query?

2013-01-02 Thread Michael Bayer
On Jan 2, 2013, at 8:33 AM, John Anderson wrote: I would like to generate this query: SELECT a.pk, aa.response FROM attendee as a JOIN field as f on f.conference_pk = a.conference_pk LEFT JOIN attendee_answer as aa ON aa.field_pk = f.pk

Re: [sqlalchemy] Getting generic results from an ORM query?

2013-01-02 Thread John Anderson
On Wednesday, January 2, 2013 1:39:28 PM UTC-3, Michael Bayer wrote: On Jan 2, 2013, at 8:33 AM, John Anderson wrote: I would like to generate this query: SELECT a.pk, aa.response FROM attendee as a JOIN field as f on f.conference_pk = a.conference_pk

Re: [sqlalchemy] Getting generic results from an ORM query?

2013-01-02 Thread Michael Bayer
On Jan 2, 2013, at 11:53 AM, John Anderson wrote: you can specify the columns: q = session.query(Attendee.pk, AttendeeAnswer.response)... Is there a way to do Attendee.*, AttendeeAnswer.response instead of listing all individually? It should work if you put the Table object in

Re: [sqlalchemy] Array with custom types in SqlAlchemy 0.8b2

2013-01-02 Thread Michael van Tellingen
Thanks for the detailed response! Inserting the values seems to work fine now. Only retrieving them again doesn't work. I've updated the gist at https://gist.github.com/4433940 The problem seems that psycopg2 now returns the array as a string ({uuid1, uuid2}) and sqlalchemy iterates over the

Re: [sqlalchemy] Array with custom types in SqlAlchemy 0.8b2

2013-01-02 Thread Michael Bayer
psycopg2 does have some adapters for this: http://initd.org/psycopg/docs/extras.html?highlight=uuid#uuid-data-type ideally using those would work transparently with ARRAY types, but its not clear if they do or not. They should, or if not you'd probably need to build a more comprehensive

Re: [sqlalchemy] Array with custom types in SqlAlchemy 0.8b2

2013-01-02 Thread Michael van Tellingen
Again, thanks for the detailed response! I went with the psycopg2.extras.register_uuid() method and that works without problems for now. I did have to remove the as_uuid=True since psycopg2 already returned it as an uuid type. For future references the working test code is here

Re: [sqlalchemy] Array with custom types in SqlAlchemy 0.8b2

2013-01-02 Thread Michael Bayer
that adapter works both ways, so you can drop the custom type completely: table = Table('example_2', metadata, Column('timestamp', DateTime(timezone=False), primary_key=True), Column('num', Integer), Column('guids', ARRAY(UUID, dimensions=1)) ) On Jan 2, 2013, at 2:10 PM, Michael

[sqlalchemy] Multiple table join selectable update vs insert

2013-01-02 Thread YKdvd
I'm starting to work with an existing MySQL setup, where there's a master database (or, effectively, schema, it is all within one MySQL instance) with tables of general usefulness, and separate schemas for each specific project. So there is a table master.users with all the basic information

[sqlalchemy] maximum number of expressions in a list is 1000

2013-01-02 Thread jo
Hi all, I need to use in_(), but in oracle it has a limit of 1000 values, there's an alternative syntax that can be used successful in oracle and it is: (field,-1) in ( (123,-1), (333,-1), ... ) I tryed this: session.query(Mytable).filter((Mytable.c.id,-1).in_([(123,-1),(333,-1)]) )