[sqlalchemy] Determine what joins are in select statement

2009-10-27 Thread Kalium
Hi, Just wondering if there is an easy way to determine what tables are joined in a query? I'm doing something like this query = session.query(System, dynamic_obj).select_from(self.j) Where dynamic_obj could be any mapped object and self.j represents a join produced by the

[sqlalchemy] Re: Multi table select?

2009-10-27 Thread Mike Conley
On Mon, Oct 26, 2009 at 10:09 PM, Bobby Impollonia bob...@gmail.com wrote: You can also create a view mapped to that union and use that as a virtual table so that you don't have to repeat the union specification for every query: http://www.w3schools.com/Sql/sql_view.asp I don't know if

[sqlalchemy] Re: How to label text columns in a query

2009-10-27 Thread Mike Conley
Only a couple of months late, but here is the final working recipe: class A(Base): __tablename__ = 'tbl_a' id = Column(Integer, primary_key=True) data = Column(String) class B(Base): __tablename__ = 'tbl_b' id = Column(Integer, primary_key=True) data = Column(String)

[sqlalchemy] Help Writing Portable Query

2009-10-27 Thread Sir Rawlins
Hello Guys, I've got a query which I'm currently running as literal SQL against a MySQL database. I'm looking to create a ported version of the query for SQLite but am totally new to that platform so am looking for a little help with my date/time functions, I'm hoping someone here will have a

[sqlalchemy] Re: Help Writing Portable Query

2009-10-27 Thread Conor
Sir Rawlins wrote: Hello Guys, I've got a query which I'm currently running as literal SQL against a MySQL database. I'm looking to create a ported version of the query for SQLite but am totally new to that platform so am looking for a little help with my date/time functions, I'm hoping

[sqlalchemy] Create database and transactional blocks strangeness

2009-10-27 Thread Wolodja Wentland
Hi all, I am having a problem getting database creation on PostgreSQL done correctly in an API that I am writing. I am using a svn checkout of SA trunk from yesterday if that is important. I have use the following code to create the database: --- snip --- ... try: import psycopg2.extensions

[sqlalchemy] Re: Create database and transactional blocks strangeness

2009-10-27 Thread Michael Bayer
Wolodja Wentland wrote: def create(self): Create this database # set isolation level to AUTOCOMMIT # postgres can't CREATE databases within a transaction self._admin_engine.connect().connection.connection.set_isolation_level( ISOLATION_LEVEL_AUTOCOMMIT)

[sqlalchemy] Re: Create database and transactional blocks strangeness

2009-10-27 Thread Wolodja Wentland
On Tue, Oct 27, 2009 at 16:22 -0400, Michael Bayer wrote: Wolodja Wentland wrote: def create(self): Create this database # set isolation level to AUTOCOMMIT # postgres can't CREATE databases within a transaction

[sqlalchemy] Re: Create database and transactional blocks strangeness

2009-10-27 Thread Michael Bayer
Wolodja Wentland wrote: On Tue, Oct 27, 2009 at 16:22 -0400, Michael Bayer wrote: Wolodja Wentland wrote: def create(self): Create this database # set isolation level to AUTOCOMMIT # postgres can't CREATE databases within a transaction

[sqlalchemy] outer join with two clauses

2009-10-27 Thread Mariano Mara
Hi everyone, how do I use two clauses in an outerjoin? e.g.: select ... from t1 outer join t2 on (t1.c1=t2.c1 and t1.c2t2.c2) According to docs, outerjoin is outerjoin(left, right, onclause=None) so I don't really know where to place the second clause. In a query object, outerjoin is

[sqlalchemy] Re: outer join with two clauses

2009-10-27 Thread David Gardner
You wrap your two conditions with and_() as your onclause. Mariano Mara wrote: Hi everyone, how do I use two clauses in an outerjoin? e.g.: select ... from t1 outer join t2 on (t1.c1=t2.c1 and t1.c2t2.c2) According to docs, outerjoin is outerjoin(left, right, onclause=None) so I

[sqlalchemy] Many to Many relationships, dynamic_loaders, etc

2009-10-27 Thread Jared Nuzzolillo
Greetings! I've known about sqlalchemy for a long time and have been interested in using it professionally for a while now. I finally have the chance to use it and have really been enjoying it. But it turns out that I am a little confused about the best way to handle m2m relationships that have

[sqlalchemy] Re: UnicodeDecodeError with pg8000 postgresql.conf client_encoding=utf8, engine encoding=utf-8

2009-10-27 Thread Kyle Schaffrick
On Sat, 24 Oct 2009 04:02:04 -0700 (PDT) sector119 sector...@gmail.com wrote: Hi All. I've got UnicodeDecodeError: 'ascii' codec can't decode byte 0xa1 in position 3: ordinal not in range(128) Why it can happen? I use client_encoding=utf8 at postgresql.conf and encoding=utf-8 at