Re: [sqlalchemy] Issue with `filter_by`?

2012-07-25 Thread Christoph Zwerschke
Am 25.07.2012 07:17, schrieb Amos: [obj.code for obj in Session.query(Model).filter_by(my_column=123).all()] [u'123ad', u'123lpb', u'123xd8', u'123za0'] I would expect no results as no column exactly matches the string representation of my number Your result will depend on how your

[sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Stephan Hügel
I need to create 20 identical (in structure) tables, each of which will have a many-to-many relationship with a particular table (Table_A). I've thought a bit about this, and there doesn't seem to be a better way to structure the setup; it's a canonical reference (Table_A), each entry of which

Re: [sqlalchemy] Issue with `filter_by`?

2012-07-25 Thread tonthon
what result do you get with : [obj.my_column for obj in Session.query(Model).filter_by(my_column=123).all()] ? Le 25/07/2012 07:17, Amos a écrit : I've defined a column declaratively like so my_column = Column(Unicode(30), index=True, unique=True) If I pass in an integer instead of a

Re: [sqlalchemy] Performance Mystery

2012-07-25 Thread Michael Bayer
does this occur with a raw mysqlconnect script ? if so, how about a MySQLdb version of the same thing ? start looking at the DBAPI. On Jul 25, 2012, at 3:45 AM, Warwick Prince wrote: I have taken the SQL entered into the MySQL Workbench (see below) and run that same SQL directly as a

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Michael Bayer
just build a function: def create_my_class(x, y, z, ...): class MyClass(Base): __tablename__ = '...' # ... MyClass.__name__ = 'SomeName%s%s' % (q, p) return MyClass On Jul 25, 2012, at 5:49 AM, Stephan Hügel wrote: I need to create 20 identical (in structure)

Re: [sqlalchemy] subquery as column

2012-07-25 Thread Michael Bayer
SQLAlchemy has two general classes of SQL construct - the FromClause and the ColumnElement. A FromClause is a thing that goes in the FROM list of a SELECT statement, whereas a ColumnElement goes into the columns clause, WHERE, ORDER BY, GROUP BY, and ON sections of a SELECT statement.A

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Stephan Hügel
On Wednesday, 25 July 2012 16:44:16 UTC+1, Michael Bayer wrote: just build a function: def create_my_class(x, y, z, ...): class MyClass(Base): __tablename__ = '...' # ... MyClass.__name__ = 'SomeName%s%s' % (q, p) return MyClass On Jul 25, 2012, at 5:49 AM,

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Michael Bayer
On Jul 25, 2012, at 4:29 PM, Stephan Hügel wrote: OK, I've done the following def create_signlist(sl): class SignList(db.Model): __tablename__ = listname.lower() id = db.Column(id, db.Integer(), primary_key=True) reference = db.Column(db.String(50),

Re: [sqlalchemy] Oracle, version_id_col, and timestamps with time zones

2012-07-25 Thread Tim
I think I've found what is causing my problems. See http://paste.ofcode.org/38cMYRa7u268EsuUnWQXjfg Also, I want to thank you for you help. It is very much appreciated. Tim On Monday, July 23, 2012 10:15:12 PM UTC-4, Michael Bayer wrote: the sqlalchemy.types.TIMESTAMP type has

Re: [sqlalchemy] Oracle, version_id_col, and timestamps with time zones

2012-07-25 Thread Michael Bayer
wow, nice job. I have to write a test for that but that's a definite high priority for the next SQLA release: http://www.sqlalchemy.org/trac/ticket/2539 On Jul 25, 2012, at 5:35 PM, Tim wrote: I think I've found what is causing my problems. See

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Stephan Hügel
On Wednesday, 25 July 2012 22:32:34 UTC+1, Michael Bayer wrote: On Jul 25, 2012, at 4:29 PM, Stephan Hügel wrote: OK, I've done the following def create_signlist(sl): class SignList(db.Model): __tablename__ = listname.lower() id = db.Column(id, db.Integer(),

Re: [sqlalchemy] Issue with `filter_by`?

2012-07-25 Thread Amos
Thanks for the quick response Christoph. I would also prefer an error over non-sensical results. Good thing we're switching to Postgres soon! On Wednesday, July 25, 2012 1:31:28 AM UTC-7, Christoph Zwerschke wrote: Am 25.07.2012 07:17, schrieb Amos: [obj.code for obj in

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Michael Bayer
On Jul 25, 2012, at 6:49 PM, Stephan Hügel wrote: if you want to make a new class that has a new name from the start, use type(): def __init__(self, reference): self.reference = reference d = dict( __tablename__ = listname.lower() id = db.Column(id, db.Integer(),

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Stephan Hügel
On Wednesday, 25 July 2012 23:52:18 UTC+1, Michael Bayer wrote: instantiate, as in, instance of the new class? my_class above is a regular Python class, just instantiate - myclass(x, y, z). What I'd like to end up with is programmatically created instances ( myapp.models.lak) that

Re: [sqlalchemy] Creating classes and many-to-many relations dynamically

2012-07-25 Thread Michael Bayer
On Jul 25, 2012, at 7:26 PM, Stephan Hügel wrote: # what do I have to do now to end up with instances Abc, Def, Ghi that I can query within my app in the same way as Foo? Let's use the right terminology, you mean class. Abc, Def, Ghi are classes - the word instance implies you