Re: [sqlalchemy] Strange bug when adding

2013-09-19 Thread Werner
Hi Mat, On 20/09/2013 01:07, Mat Leonard wrote: I'm having a problem adding class Session(Base): __tablename__ = 'sessions' id = sql.Column(sql.Integer, primary_key=True units = sql.orm.relationship("Unit", order_by="Unit.id",

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
On Sep 19, 2013, at 3:07 PM, Michael Bayer wrote: > > On Sep 19, 2013, at 2:46 PM, Nathan Mailg wrote: > >> c = aliased(City) >> q2 = s.query(q1).\ >> join(Appl.city).\ >> join(c, Appl.city).\ >> order_by(q1.c.lastname, q1.c.firstname) > > why don't you join on the Column obj

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
That's it, awesome! Thank you! >>> q2 = s.query(q1).order_by(q1.c.lastname, q1.c.firstname) >> Sorry to tag on a followup, but how would I get the following relationship >> mapped onto the 2nd, non-distinct SELECT ("q2" above)? From the "Appl" class >> below: >> city = relationsh

[sqlalchemy] Strange bug when adding

2013-09-19 Thread Mat Leonard
I'm having a problem adding class Session(Base): __tablename__ = 'sessions' id = sql.Column(sql.Integer, primary_key=True units = sql.orm.relationship("Unit", order_by="Unit.id", backref="session",

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Michael Bayer
On Sep 19, 2013, at 2:46 PM, Nathan Mailg wrote: > > c = aliased(City) > q2 = s.query(q1).\ >join(Appl.city).\ >join(c, Appl.city).\ >order_by(q1.c.lastname, q1.c.firstname) why don't you join on the Column objects present rather than relying on the relationship?

Re: [sqlalchemy] api omission? the postgres "DISTINCT ON(columns)" is only in the ORM, not in the sql expression

2013-09-19 Thread Jonathan Vanasco
Oh crap. I understand. I was trying to do this: query = select( func.distinct( columns ) ) and not query = distinct( columns ) i got thrown off, because the postgres tool is more like a function than an query , and there's also the .distinct() method you can toss onto a query; alm

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
Using q1: q1 = s.query(Appl).\ distinct(Appl.refid).\ filter(Appl.lastname.ilike('Williamson%')).\ filter(Appl.firstname.ilike('d%')).\ group_by(Appl).\ order_by(Appl.refid, Appl.appldate.desc()) this q2 works as a simple join: q2 = s.query(q1).\ j

Re: [sqlalchemy] Problem inserting records in blob column

2013-09-19 Thread Michael Bayer
On Sep 19, 2013, at 11:09 AM, erikamont...@libero.it wrote: > Hi everyone, > > I'm using SQLalchemy 0.7.10 and I'm encountering some problems trying to > insert > records inside a table in a blob column. > The error I get is the following: > > StatementError: 'SQLiteExecutionContext' object

[sqlalchemy] Problem inserting records in blob column

2013-09-19 Thread erikamontani
Hi everyone, I'm using SQLalchemy 0.7.10 and I'm encountering some problems trying to insert records inside a table in a blob column. The error I get is the following: StatementError: 'SQLiteExecutionContext' object has no attribute 'fire_sequence' (original cause: AttributeError: 'SQLiteExecut

Re: [sqlalchemy] Dialect dependent REPLACEs

2013-09-19 Thread Michael Bayer
On Sep 17, 2013, at 6:32 PM, Samer Atiani wrote: > Hello, > > I'm trying to write a custom REPLACE expression that compiles differently on > MySQL vs sqlite, namely it would look like REPLACE INTO in mysql and INSERT > OR REPLACE in sqlite. I implemented it like so: > > class ReplaceInto(Val

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Michael Bayer
OK, like this then: q1 = s.query(Appl).distinct(Appl.refid).\ filter(Appl.lastname.ilike('Williamson%')).\ filter(Appl.firstname.ilike('d%')).\ group_by(Appl).\ order_by(Appl.refid, Appl.appldate.desc()) output: WITH distinct_query AS (SELECT DISTIN

Re: [sqlalchemy] api omission? the postgres "DISTINCT ON(columns)" is only in the ORM, not in the sql expression

2013-09-19 Thread Michael Bayer
the standalone function "distinct" is only in core can you be more specific here "distinct on" is specific to posrtgresql, and is provided by select.distinct, query.distinct. the latter makes use of the former, so obviously both have the same features. On Sep 18, 2013, at 8:36 PM, Jonathan

Re: [sqlalchemy] Running SQL Alchemy on a QNX RTOS Machine

2013-09-19 Thread Michael Bayer
On Sep 18, 2013, at 1:21 PM, Daniel Weissberger wrote: > I am a considering using SQLAlchemy for ORM. I have a couple of concerns up > front I wanted to share with you. > > **The machine running Python will be a QNX RTOS Machine > > Currently I have 32 bit MS Access installed on a 64 bit m

Re: [sqlalchemy] SQLAlchemy hot-copy capability

2013-09-19 Thread Richard Gerd Kuesters
*src* can be an in memory database, it works too :) on backup, I just use: *destdb = apsw.Connection(__DATABASE_FILE__)** **with destdb.backup("main", _connection, "main") as backup:** **while not backup.done:** **backup.step(100)* it's a bit faster

Re: [sqlalchemy] SQLAlchemy hot-copy capability

2013-09-19 Thread pr64
HI everyone, First, i would like to thank you for your comments. Then, for those who run linux, the following works: 1- copy your db.sqlite to /dev/shm/db.sqlite (thus in ram fs) 2- play with it through sqlalchemy 3- backup it to disk when needed src = apsw.Connection(ram