[sqlalchemy] Opinion on correct use of Sqlalchemy

2007-04-07 Thread HD Mail
Hi, I was after some opinions on the following use of SA. 1. Is there any problems using SA in this way ? 2. Is there better ways of achieving this ? My Mapper db.mapper(Asset, db.asset_table, properties = { 'location': relation(Location, lazy=False), 'type':

[sqlalchemy] SQLite and decimal.Decimal

2007-04-07 Thread [EMAIL PROTECTED]
Hi, I'm using SQLite in tests and there is a problem when using decimal.Decimal with sqlalchemy's Numeric type: SQLError: (InterfaceError) Error binding parameter 5 - probably unsupported type. This is not a new issue, a similar one was posted in

[sqlalchemy] Re: SQLite and decimal.Decimal

2007-04-07 Thread Michael Bayer
the thing is, we have support for 6 different databases and postgres is the *only* one where its DBAPI implementation decides to use Decimal for numeric types. the rest return just floats. that means, people who have worked with databases other than postgres will be totally surprised to

[sqlalchemy] Converting queries to mappings

2007-04-07 Thread Benn Bollay
Hi all - I want to convert a handful of complicated queries into properties, for simplicity and ease of maintaince. I currently have a function in my class called 'dependencies': def dependencies(self): parent = DataRun.CMDS.alias('PARENT') return

[sqlalchemy] Re: simple DateTime select

2007-04-07 Thread desmaj
Hi Ryan, On Apr 7, 6:10 pm, rkennedy [EMAIL PROTECTED] wrote: I'm new to SQLAlchemy and am trying to select objects from the following table that occurred before a specified date. I'm pretty new myself, but I've been reading the docs a bunch today and I may be able to help. event_table =

[sqlalchemy] Re: Converting queries to mappings

2007-04-07 Thread Benn Bollay
Ah ok. Basically, yeah, I'm trying to put all the 'mapper' type behaviors in one place, instead of having some of the properties specified where I declare the mapper, and others declared as functions in the class itself. There might be a better python-esque way of doing this, I admit, but I

[sqlalchemy] Re: simple DateTime select

2007-04-07 Thread rkennedy
Thanks, Matthew. Looks like SA is still complaining about the global name not being defined. event = self.sess.query(model.Event).get_by(event_table.c.start_time '2007-10-19 10:23:54') The above code produces a similar error... NameError: global name 'event_table' is not defined When I try

[sqlalchemy] Re: simple DateTime select

2007-04-07 Thread desmaj
Hi Ryan, On Apr 7, 8:44 pm, rkennedy [EMAIL PROTECTED] wrote: Thanks, Matthew. Looks like SA is still complaining about the global name not being defined. event = self.sess.query(model.Event).get_by(event_table.c.start_time '2007-10-19 10:23:54') The above code produces a similar

[sqlalchemy] Re: simple DateTime select

2007-04-07 Thread rkennedy
Hi Matthew, Your assessment was spot on. Apparently the start_time field also needed an explicit reference to the database table import. The following query now does the trick... events = self.sess.query(model.Event).select_by(model.Event.c.start_time '2007-10-19 10:23:54') Thanks again for

[sqlalchemy] Re: Converting queries to mappings

2007-04-07 Thread Michael Bayer
On Apr 7, 2007, at 8:19 PM, Benn Bollay wrote: How about getting a different existing Table object for a table that's not mapped to a class? I don't want to call Table(...,autoload=True) again because that sounds like it'd load the entire metadata for the table each time the function was

[sqlalchemy] Re: simple DateTime select

2007-04-07 Thread Michael Bayer
FYI the comparisons to a DateTime column are better done against a similar datetime() object, rather than a string - select(table.c.date_col datetime.datetime(2007, 10, 19, 10, 23, 54)) On Apr 7, 2007, at 11:44 PM, rkennedy wrote: Hi Matthew, Your assessment was spot on. Apparently the