[sqlalchemy] Re: dictionary returning a collection

2008-01-18 Thread Christophe Alexandre
Great! The solution #3 seems especially appealing ... Thank you for the comprehensive answer! -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jason kirtland Sent: Thursday, January 17, 2008 7:53 PM To: sqlalchemy@googlegroups.com Subject:

[sqlalchemy] Re: Relating objects of the same type Using Joined Table Inheritance

2008-01-18 Thread sdobrev
you relation should have argument like primary_join= engineers.c.hired_by_id==managers.c.employee_id or similar. i do not know for sure as i've done a layer on top of SA that stores most of this knowledge, so i dont bother with it. Have a look at dbcook.sf.net. u may use it as ORM to build and

[sqlalchemy] Re: dictionary returning a collection

2008-01-18 Thread Christophe Alexandre
Dear All, Just to let you know how I solved my problem: according to the solution #3 described below by Jason, I created in my local sqlalchemy installation a MultiValuedMappedCollection class in the sqlalchemy.orm.collections package Based on the MappedCollection class. The newly created class

[sqlalchemy] Filter by year in datetime column

2008-01-18 Thread [EMAIL PROTECTED]
Hello, pleas, i have begginer problem and question: In table (database is sqlite) is colum for create date (create_date = Field(DateTime, default = datetime.now)) I need query from table, with all item where have year of create date 2007. Is this the right way ? (this don`t work) data =

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread King Simon-NFHD78
Would create_date = '2007-01-01' and create_date '2008-01-01' be acceptable? If so, something like this should work from sqlalchemy import and_ from datetime import date data = Table.query().filter(and_([Mikropost.c.create_date = date(2007, 1, 1),

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread Andreas Jung
--On 18. Januar 2008 12:08:46 -0500 Rick Morrison [EMAIL PROTECTED] wrote: There are no generic date functions in SQLAlchemy (although work has begun on them). So for now, you'll need to use date functions native to your database. For sqlite something like, func.strftime('%Y',

[sqlalchemy] Re: Error while setting default dates on a table with default=func.now()

2008-01-18 Thread Michael Bayer
On Jan 18, 2008, at 10:59 AM, Hermann Himmelbauer wrote: Hi, I have a table that looks appr. like this (I deleted some columns): table_acc = Table( 'konto', metadata, Column('kontoid', Integer, primary_key=True, key='accid'), Column('erdat', DateTime, default=func.now(),

[sqlalchemy] Re: Error while setting default dates on a table with default=func.now()

2008-01-18 Thread Michael Bayer
On Jan 18, 2008, at 5:29 PM, Hermann Himmelbauer wrote: Am Freitag, 18. Januar 2008 22:43 schrieb Michael Bayer: On Jan 18, 2008, at 10:59 AM, Hermann Himmelbauer wrote: Hi, I have a table that looks appr. like this (I deleted some columns): table_acc = Table( 'konto', metadata,

[sqlalchemy] Problems connecting to Postgresql using collective.lead

2008-01-18 Thread Alex Turner
I am getting an error connecting to Postgresql: ImportError: unknown database 'psycopg' The back story is that I am attempting to modify an example given in Martin Aspeli's Book: Professional Plone Development (Chapter 12 - page 274-. He recommends using SQLAlchemy, and it looks very cool, kind

[sqlalchemy] Error while setting default dates on a table with default=func.now()

2008-01-18 Thread Hermann Himmelbauer
Hi, I have a table that looks appr. like this (I deleted some columns): table_acc = Table( 'konto', metadata, Column('kontoid', Integer, primary_key=True, key='accid'), Column('erdat', DateTime, default=func.now(), key='datopen')) What I'd like to accomplish is that when during an

[sqlalchemy] Re: Readonly objects/protecting objects from modifications

2008-01-18 Thread klaus
Hi all, it's only now that I came across this interesting discussion. I tried similar things but what I wanted to protect was my cached data. And session.merge(obj, dont_load=True) triggers these AssertionErrors. :-( So I went for a MapperExtension instead. The after_update method can still

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread Rick Morrison
There are no generic date functions in SQLAlchemy (although work has begun on them). So for now, you'll need to use date functions native to your database. For sqlite something like, func.strftime('%Y', Mikropost.c.create_date) == '2008' should work -- you may need to add additional percent

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread Rick Morrison
Such operations will likely trigger a full table scan SQLite dates are stored as strings anyway, AFAIK there is little one can do to avoid table-scans in SQLite based solely on date criteria. I use julian dates stored as integers when working with large datasets in SQLite, and convert as needed.

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread sdobrev
Rick Morrison wrote: Such operations will likely trigger a full table scan SQLite dates are stored as strings anyway, AFAIK there is little one can do to avoid table-scans in SQLite based solely on date criteria. I use julian dates stored as integers when working with large datasets in

[sqlalchemy] Re: Error while setting default dates on a table with default=func.now()

2008-01-18 Thread Hermann Himmelbauer
Am Freitag, 18. Januar 2008 22:43 schrieb Michael Bayer: On Jan 18, 2008, at 10:59 AM, Hermann Himmelbauer wrote: Hi, I have a table that looks appr. like this (I deleted some columns): table_acc = Table( 'konto', metadata, Column('kontoid', Integer, primary_key=True,