[sqlalchemy] Re: SQL: using BETWEEN with char fields

2011-04-25 Thread Marco
I would create a min and max columns in that same table or in a separate index table, and parse the value in advance so that the min column has the 1 and the max column the 3, then you can issue a normal query against the two columns. For single values max=min. I am sure that there are ways to

[sqlalchemy] Re: Strange occasional ProgrammingError: Cannot operate on a closed database

2011-04-25 Thread Kent Hsu
I got the same error. My web applicaiton works fine with sa0.5, but does not work since sa0.6. The situation is much like the follow link. https://github.com/Pylons/pyramid/issues/174 Best Regards, Kent Hsu On 4月22日, 上午11時36分, Roy H. Han starsareblueandfara...@gmail.com wrote: Lately, I've

Re: [sqlalchemy] Re: Strange occasional ProgrammingError: Cannot operate on a closed database

2011-04-25 Thread Michael Bayer
the refresh 50 times aspect suggests it's concurrency-related. SingletonThreadpool, the pool the SQLite dialect uses in 0.6, isn't the best choice for a file-based database so I'd recommend switching to NullPool which is the default in 0.7. On Apr 25, 2011, at 5:05 AM, Kent Hsu wrote: I

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-25 Thread Michael Bayer
On Apr 25, 2011, at 12:59 AM, Andrey Petrov wrote: So if I understand correctly, You would choose the (1) assoc_id/type secondary table approach that you outline in the blog post over having (2) redundant schema per-table with direct FKs (FooTag, BarTag, etc)? Why? (I have a feeling I'm

Re: [sqlalchemy] Re: replacing or altering a mapper?

2011-04-25 Thread Daniel Holth
I suppose you explicitly don't want to call User.morestuff.otherproperty? I like doing it that way, but it could be that I am underusing SQLAlchemy's inheritance features. The following works fine: package 1: Base1 = declarative_base() class User(Base1): pass package 2: Base2 =

[sqlalchemy] Constructor and destructor of mapped objects

2011-04-25 Thread Dmitry Guryanov
Hello, i'm writing web-based photo gallery using pylons have the following question: Each photo in gallery have one row in 'photos' table and files on disk (original file and preview). I have Photo class, mapped to photos table: class Photo(Base): __tablename__ = photos id =

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-25 Thread Andrey Petrov
Thanks Michael! I am crawling and annotating portions of Twitter's social graph, so I'm already approaching 1mil rows. I'm trying to hold off sharding as long as I can. :) Concrete table style sounds most sensible, despite the schema clutter. I need to write some kind of Taggable factor to

Re: [sqlalchemy] Re: SQL: using BETWEEN with char fields

2011-04-25 Thread Michael Bayer
On Apr 25, 2011, at 1:08 AM, Marco wrote: I would create a min and max columns in that same table or in a separate index table, and parse the value in advance so that the min column has the 1 and the max column the 3, then you can issue a normal query against the two columns. For single

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-25 Thread Andrey Petrov
One more thought: Is there a sane way to hide a schema object within another schema object? Specifically, I want to make a factory method (or maybe a class decorator) which generates these Tag schemas onto specific tables. Something along the lines of: @Taggable class User(BaseModel)

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-25 Thread Andrey Petrov
Looks like this almost-sorta works: class TagMixin(object): @declared_attr def TagClass(cls): class Tag(BaseModel): __tablename__ = tag_%s % cls.__tablename__ id = Column(types.Integer, primary_key=True) time_created = Column(types.DateTime,

[sqlalchemy] Re: how to have indexed columns in table definition?

2011-04-25 Thread Andrey Petrov
There's two ways: 1. You can put an index=True argument on the Column, such as... class Foo(Base): name = Column(types.String, index=True) 2. You can create Index() definitions just like you create Column() definitions. If you're using 0.6.x, the Index() definition must be outside of

[sqlalchemy] Re: Best design for commits?

2011-04-25 Thread Andrey Petrov
Hi Aviv, Since your bottleneck is fetching the urls, I suggest you look at using workerpool http://code.google.com/p/workerpool/ with urllib3. It helps you do exactly what Michael describes. (Disclaimer: I wrote both, workerpool and urllib3. They were built to complement each other.) There