Re: [sqlalchemy] to many statements for collection.append?

2011-11-10 Thread Michael Bayer
On Nov 9, 2011, at 3:37 AM, sector119 wrote: > > ### TEST 2 > # HERE I GOT ERROR if I uncomment "user = ..." line > > session = Session() > > report = session.query(Report).get(1) > #user = session.query(User).filter_by(username='sector119').one() > comment = Comment(content=u'test comment', u

Re: [sqlalchemy] UniqueConstraint with func

2011-11-10 Thread Michael Bayer
id never heard of a functional unique constraint but there you go, here's a stack overflow answer for this one: http://stackoverflow.com/questions/1510018/compound-uniqueconstraint-with-a-function On Nov 10, 2011, at 1:15 AM, lestat wrote: > Can I add UniqueConstraint like this? > > > from

Re: [sqlalchemy] Getting ENUM-like behavior from a MySQL VARCHAR

2011-11-10 Thread Michael Bayer
On Nov 9, 2011, at 5:27 PM, Ryan wrote: > I have a MySQL VARCHAR column, but I'd like to get ENUM-like behavior at the > ORM level. I'm using the declarative style. Here's what I've got so far: > > language = Column(Enum('en', 'fr', native_enum=False), CheckConstraint(), > default='en') > > D

Re: [sqlalchemy] subqueryload problem

2011-11-10 Thread Michael Bayer
On Nov 10, 2011, at 11:59 AM, Ian Wilson wrote: > I'm not sure if this is a case of user error or what but I'm trying to > use a double sub-query load. The odds are probably pretty good that > I'm doing something wrong. I just finally got around to trying > subqueryload and I think it is what I

Re: [sqlalchemy] default NULL

2011-11-10 Thread Michael Bayer
On Nov 10, 2011, at 2:09 AM, lestat wrote: > How I can add default NULL for column? > > class UserIp(db.Model, UnicodeMixin): >__tablename__ = 'user_ip' > >user_id = db.Column(db.Integer, db.ForeignKey('user.id'), > primary_key=True, nullable=True, server_default=None) >ip = db.Colu

[sqlalchemy] subqueryload problem

2011-11-10 Thread Ian Wilson
I'm not sure if this is a case of user error or what but I'm trying to use a double sub-query load. The odds are probably pretty good that I'm doing something wrong. I just finally got around to trying subqueryload and I think it is what I've been looking for my entire life. Although the SQL bei

Re: [sqlalchemy] Dynamic data member instrumentation with declarative

2011-11-10 Thread Mark Erbaugh
On Nov 10, 2011, at 12:57 PM, Michael Bayer wrote: > > On Nov 10, 2011, at 9:34 AM, Mark Erbaugh wrote: > >> I'm trying to use data from a sequence to add columns to a SQLAlchemy table >> created declaratively. Here's what I'm doing: >> >> class Sizing(Base): >> __tablename__ = 'sizing' >>

Re: [sqlalchemy] Dynamic data member instrumentation with declarative

2011-11-10 Thread Michael Bayer
On Nov 10, 2011, at 9:34 AM, Mark Erbaugh wrote: > I'm trying to use data from a sequence to add columns to a SQLAlchemy table > created declaratively. Here's what I'm doing: > > class Sizing(Base): >__tablename__ = 'sizing' >id = Column(Integer, primary_key=True) > >[...] > > >

[sqlalchemy] Dynamic data member instrumentation with declarative

2011-11-10 Thread Mark Erbaugh
I'm trying to use data from a sequence to add columns to a SQLAlchemy table created declaratively. Here's what I'm doing: class Sizing(Base): __tablename__ = 'sizing' id = Column(Integer, primary_key=True) [...] for name in ('column1', 'column2', 'column3', ...): x = Column(typ

[sqlalchemy] Re: sqlalchemy-migrate 0.7.2 released

2011-11-10 Thread Frédéric Bertolus
Hello, I'm not an artist but I just tried to make a logo artwork for SqlAlchemy-Migrate. http://dev.elveos.org/sqlalchemy-migrate-logo/sql_alchemy_migrate.html The logo is a reference to the swallow problem in "Monty Python and the Holy Grail". Fred Elveos Developer https://elveos.org On 2 n

[sqlalchemy] Re: sqlite and "database is locked" errors.

2011-11-10 Thread Matthew Newville
Michael, Thanks! Using create_engine(..., poolclass=SingletonThreadPool) works perfectly, though create_engine(..., pool_threadlocal=True) still showed similar database is locked on 'session commit' FWIW, I do have a single engine, connection, and session in the application, as with (now):

[sqlalchemy] default NULL

2011-11-10 Thread lestat
How I can add default NULL for column? class UserIp(db.Model, UnicodeMixin): __tablename__ = 'user_ip' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True, nullable=True, server_default=None) ip = db.Column(postgres.CIDR, nullable=False, server_default='127.0.0.

[sqlalchemy] UniqueConstraint with func

2011-11-10 Thread lestat
Can I add UniqueConstraint like this? from sqlalchemy import func from sqlalchemy.schema import UniqueConstraint from sqlalchemy.dialects import postgres class UserIp(db.Model): __tablename__ = 'user_ip' __table_args__ = ( UniqueConstraint('user_id', func.md5('ip')), )