[sqlalchemy] Re: Get default value

2008-01-11 Thread Alexandre da Silva
Em Sex, 2008-01-11 às 08:54 +0200, [EMAIL PROTECTED] escreveu: either put the correct polymorphic_on=resource.c.poly, or remove it alltogether, it comes from the inherited base-mapper. Exactly, works fine leaving poly on resource and mapping all polymorphic_on=resource.c.poly cookbook

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre Conrad
svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist (instance of Playlist). At this point, I need to find out the

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: svilen wrote: Here is the syntax followed by the generated query: query.filter(Catalog.c.id==CatalogChannel.c.id) WHERE catalogs.id = catalogs.id why u need such a query? that's exactly what (inheritance) join does, and

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Jonathan LaCour
Jonathan LaCour wrote: I am attempting to model a doubly-linked list, as follows: ... seems to do the trick. I had tried using backref's earlier, but it was failing because I was specifying a remote_side keyword argument to the backref(), which was making it blow up with cycle detection

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Denis S. Otkidach
On Jan 11, 2008 7:57 PM, Jonathan LaCour [EMAIL PROTECTED] wrote: Jonathan LaCour wrote: I am attempting to model a doubly-linked list, as follows: ... seems to do the trick. I had tried using backref's earlier, but it was failing because I was specifying a remote_side keyword

[sqlalchemy] doubly-linked list

2008-01-11 Thread Jonathan LaCour
All, I am attempting to model a doubly-linked list, as follows: task_table = Table('task', metadata, Column('id', Integer, primary_key=True), Column('name', Unicode), Column('next_task_id', Integer,

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 13:58:34 Alexandre Conrad wrote: Hi, playing with inheritance, I figured out that an inherited mapped class passed to filter doesn't point to the correct table. I have 2 classes, Catalog and CatalogChannel(Catalog). Here is the syntax followed by the generated

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 17:03:06 Alexandre Conrad wrote: svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist

[sqlalchemy] filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre Conrad
Hi, playing with inheritance, I figured out that an inherited mapped class passed to filter doesn't point to the correct table. I have 2 classes, Catalog and CatalogChannel(Catalog). Here is the syntax followed by the generated query: query.filter(Catalog.c.id==CatalogChannel.c.id)

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Jonathan LaCour
Jonathan LaCour wrote: I am attempting to model a doubly-linked list, as follows: Replying to myself: task_table = Table('task', metadata, Column('id', Integer, primary_key=True), Column('name', Unicode), Column('next_task_id', Integer, ForeignKey('task.id')),

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Michael Bayer
On Jan 10, 2008, at 9:15 PM, deanH wrote: Hello, I am having a problem inserting an object into a MS SQL table that contains a timestamp field (now) that is generated automatically - sqlalchemy is defaulting this column to None and when it is generating the SQL insert. Is there a way to

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Michael Bayer
On Jan 11, 2008, at 10:03 AM, Alexandre Conrad wrote: svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Michael Bayer
All of the crazy mappings today are blowing my mind, so I'll point you to an old unit test with a doubly linked list: http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/test/orm/inheritance/poly_linked_list.py the above uses just a single foreign key (but we can still traverse bi-

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre Conrad
svilen wrote: Here is the syntax followed by the generated query: query.filter(Catalog.c.id==CatalogChannel.c.id) WHERE catalogs.id = catalogs.id why u need such a query? that's exactly what (inheritance) join does, and automaticaly - just query( CatalogChannel).all() would give u

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Jonathan LaCour
Michael Bayer wrote: All of the crazy mappings today are blowing my mind, so I'll point you to an old unit test with a doubly linked list: Yeah, trust me, it was blowing my mind as well, so I elected not to go this direction anyway. You're also correct that there isn't _really_ a need to

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-11 Thread Michael Bayer
On Jan 11, 2008, at 12:30 PM, Denis S. Otkidach wrote: # Another program. We have to insure that object with id=1 exists in DB and has # certain properties. obj2 = ModelObject(1, u'title2') session.merge(obj2) session.commit() what that looks like to me is that you're attempting to

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-11 Thread Denis S. Otkidach
On Dec 28, 2007 6:25 PM, Michael Bayer [EMAIL PROTECTED] wrote: On Dec 28, 2007, at 5:50 AM, Denis S. Otkidach wrote: Sure, I can get an object from DB and copy data from new one. But there is a lot of object types, so have to invent yet another meta description for it (while it already

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre da Silva
I think I understand what you trying to do in fact polymorphic objects are load correctly in my test, I think it is an approach to your case. follow the code I used before to ask about polymorphic inheritance, note to the Catalog class, this class have a resource list (catalog_id on Resource),

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Dean Halford
Thanks for the responses guys. The PassiveDefault() parameter did exactly what I wanted it to do - which was to exclude that column from the generated insert query so that MS SQL could handle those on it's own. ... now to figure out why I am getting an unsubscriptable object type error from the

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Michael Bayer
On Jan 11, 2008, at 4:37 PM, Dean Halford wrote: Thanks for the responses guys. The PassiveDefault() parameter did exactly what I wanted it to do - which was to exclude that column from the generated insert query so that MS SQL could handle those on it's own. ... now to figure out why I

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Rick Morrison
MSSQL ID generation is limited to integer PKs of the IDENTITY type, and they work fine in 0.4 series. That wiki page should be updated. It's most likely a case of the Table not knowing that the PK should be an auto-increment type. Are you defining the table via an SA Table() definition, or trying

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Dean Halford
thanks micheal - the only reason we went with 3.11 was the following statement on the wiki: Currently (Aug 2007) the 0.4 branch has a number of problems with MS- SQL. http://www.sqlalchemy.org/trac/wiki/DatabaseNotes#MS-SQL I checked the logs and it does have to do with the MS-SQL ID generation,

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Michael Bayer
its updated. Dean, try to get on 0.4 ! On Jan 11, 2008, at 5:45 PM, Rick Morrison wrote: MSSQL ID generation is limited to integer PKs of the IDENTITY type, and they work fine in 0.4 series. That wiki page should be updated. It's most likely a case of the Table not knowing that the PK

[sqlalchemy] Re: MySQL encoding

2008-01-11 Thread phasma
What character set is the db-api driver using?  Try:   engine.connect().connection.character_set_name() If it's not utf8, you can configure the driver by adding 'charset=utf8' to your database url. I add charset='utf-8' to 'create_engine' function, but before send data(from query) to mako

[sqlalchemy] Re: MySQL encoding

2008-01-11 Thread jason kirtland
phasma wrote: What character set is the db-api driver using? Try: engine.connect().connection.character_set_name() If it's not utf8, you can configure the driver by adding 'charset=utf8' to your database url. I add charset='utf-8' to 'create_engine' function, but before send

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Dean Halford
That's unfortunate because our database is built around MS GUIDs and not integer PKs, but good to know. I am just using pythoncom.CreateGuid() to generate the object ids before insert and that is working great. thanks for all the help On Jan 11, 2:45 pm, Rick Morrison [EMAIL PROTECTED] wrote:

[sqlalchemy] Re: MySQL encoding

2008-01-11 Thread phasma
On 12 янв, 04:07, jason kirtland [EMAIL PROTECTED] wrote: phasma wrote: What character set is the db-api driver using?  Try:   engine.connect().connection.character_set_name() If it's not utf8, you can configure the driver by adding 'charset=utf8' to your database url. I add

[sqlalchemy] Re: Exclude Autogenerated Timestamp Column

2008-01-11 Thread Rick Morrison
My experience with GUID PKs is that they almost always cause more troubles than they purport to solve, and 99% of the time a plain Integer PK will work just fine instead. The two rare exceptions are with multi-database synchronization (and even there integer PKs can work fine with an additional