[sqlalchemy] in_ Subselect

2009-04-28 Thread Mike Lewis
Hi, This might be a noob question, but I am trying to reproduce the following sql query in SA select user_id, friend_id from follows where friend_id not (in select id from users); First, I do this: subquery = Session.query(User.id).subquery() Then q =

[sqlalchemy] Re: Overriding reflected columns in SqlSoup?

2009-04-28 Thread Stephen Emslie
Hi Neil I managed to make queries on those tables by creating a new table definition and getting a class mapping from that explicitly, for example: from sqlalchemy.ext.sqlsoup import SqlSoup from sqlalchemy import * engine = create_engine('sqlite:///:memory:') metadata =

[sqlalchemy] Re: in_ Subselect

2009-04-28 Thread Michael Bayer
cant reproduce. test case: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base metadata = MetaData() Base = declarative_base(metadata=metadata) class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True)

[sqlalchemy] Re: in_ Subselect

2009-04-28 Thread Mike Lewis
That's incredibly strange, because I ran your exact code and got this for output SELECT follows.friend_id FROM follows, (SELECT users.id AS id FROM users) AS anon_1 WHERE follows.friend_id NOT IN SELECT users.id FROM users I checked which version of SA I was running and it was 0.5.2 Upgraded

[sqlalchemy] secondary table order by count help

2009-04-28 Thread Krishgy
posts_table = sa.Table('posts', metadata, sa.Column(id,sa.Integer, sa.Sequence ('post_id_seq'), primary_key=True), sa.Column('userid', sa.types.Integer, sa.ForeignKey('users.id'), nullable = False), sa.Column('title',

[sqlalchemy] reflection with app server

2009-04-28 Thread paul
hello, i am looking for help and explanation to reflect tables in context of app server like cherrypy. i can't find a 'place' to auto-load and map tables. if you do it as part of cp start thread (e.g. http://cherrypy.org/wiki/CustomPlugins, http://tools.cherrypy.org/wiki/Databases), we load/map

[sqlalchemy] InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-28 Thread Daniel
Hello, In my application I have a function that looks more or less like this def run(self): # process first object in sequence for firstObject in firstObjects: self.session.add(firstObject) self.session.commit() # process second object in

[sqlalchemy] InvalidRequestError: The transaction is inactive... using sqlite and multiple commits

2009-04-28 Thread Daniel
Hello, In my application I have a function that looks more or less like this def run(self): # process first object in sequence for firstObject in firstObjects: self.session.add(firstObject) self.session.commit() # process second object in

[sqlalchemy] Re: InvalidRequestError: The transaction is inactive due to a rollback... using sqlite with multiple commits.

2009-04-28 Thread Michael Bayer
squelching typically means one of two things. either you're doing this: try: # do stuff with session except: print error ! # .. keep going or, you are allowing concurrent access to a single session with multiple threads, one of your threads is throwing an exception (usually

[sqlalchemy] obtaining a table schema

2009-04-28 Thread Paul Rigor (gmail)
Hi gang, I've recently started using sqlalchemy, so hopefully this isn't a stupid question... I was wondering whether there was an easy way to obtain a particular table's schema if one is using just bare connection (ie, not using any special orm's). Specifically, is there a utility method