import sqlalchemy
def index_in(col, valuelist):
return sqlalchemy.case([(value,idx) for idx,value in enumerate
(valuelist)], value=col)
session.query(C).filter(C.someattr.in_(valuelist)).order_by(index_in
(C.someattr, valuelist))
Don't try to do this with huge lists of items.
On Feb 25,
You can get the column object from the string, using:
xyz.c[column_name]
Do you mean that this:
columns = [a,b,c]
operators = ['+','-']
should result in xyz.c.a + xyz.c.b - xyz.c.c ?
To do that, something like this works:
columns = [a,b,c]
operators = ['+','-']
colnames_and_ops =
commit() by default expires all the attributes on all instances.
See the documentation on Using the Session for details about this.
Also a single Session should never be accessed by concurrent threads,
referring to the previous email where you got a SQLite error regarding
concurrency.
On Feb 26, 2009, at 1:29 AM, 一首诗 wrote:
The document says:
Expunge removes an object from the Session, sending persistent
instances to the detached state, and pending instances to the
transient state:
Hello,
A couple of questions on the tutorial:
1) Why .all() in 3rd (and some others) query code box, but not
others?
2) Filter clause: Why '==' vs. '=' used in .filter() vs. .filter_by
()
3) Common Filter Operators: Why or_(), and_(), in_(), but like().
(instead of like_() )
4) Common
On Feb 26, 2009, at 12:40 AM, a.fowler wrote:
Hello,
A couple of questions on the tutorial:
1) Why .all() in 3rd (and some others) query code box, but not
others?
.all() is essentially equivalent to list(query). Some of the
examples already iterate the query, such as for x in
Thanks. But using a CASE clause becomes objectionable in exactly those cases
where I would want to have the DB do the sorting — i.e. where the table is
big enough that just sorting the result set in python code using array index
(rows.sort(key=lambda row: values.index(row[0]))) would be a Bad
Previously Michael Bayer wrote:
On Feb 26, 2009, at 8:21 AM, Wichert Akkerman wrote:
What happens if you do not call expunge on it, but pickle the object
in a
cache, load it later and then merge it?
the state of the newly unpickled object, that is the current value of
its mapped
On Feb 26, 2009, at 10:27 AM, Wichert Akkerman wrote:
Previously Michael Bayer wrote:
On Feb 26, 2009, at 8:21 AM, Wichert Akkerman wrote:
What happens if you do not call expunge on it, but pickle the object
in a
cache, load it later and then merge it?
the state of the newly unpickled
A couple of questions on the tutorial:
1) Why .all() in 3rd (and some others) query code box, but not
others?
.all() is essentially equivalent to list(query). Some of the
examples already iterate the query, such as for x in query: print x,
others don't - but the tutorial wants you
On Feb 26, 2009, at 11:49 AM, a.fowler wrote:
I don't know if the docs team reads this, but here are a couple of
comments:
I'm pretty much the documentation team :).but my time is very
short these days, would you be interested in submitting a patch
against the documentation source
I am doing some work on a SA engine for Sybase Adaptive Server
Enterprise (ASE) on top of both pyodbc and the Sybase DB-API driver.
The existing sybase engine for SA only works with Sybase Anywhere
(ASA).
There is a problem with named parameters with the Sybase driver in
that the placeholders
On Feb 26, 2009, at 3:55 PM, phrrn...@googlemail.com wrote:
I am doing some work on a SA engine for Sybase Adaptive Server
Enterprise (ASE) on top of both pyodbc and the Sybase DB-API driver.
The existing sybase engine for SA only works with Sybase Anywhere
(ASA).
that is correct ; I've
Thanks Michael. I have a sybase.py passing *some* unit tests with both
pyodbc and the Sybase driver, both running on Solaris 10 x86 against
ASE 15. This is a hack that seems to work for the Sybase DBAPI module.
I do have access to lots and lots of different Sybase stuff so I will
start from your
we have ticket 785 for this:
http://www.sqlalchemy.org/trac/ticket/785
On Feb 26, 2009, at 4:45 PM, phrrn...@googlemail.com wrote:
Thanks Michael. I have a sybase.py passing *some* unit tests with both
pyodbc and the Sybase driver, both running on Solaris 10 x86 against
ASE 15. This is a
Michael Bayer wrote:
On Feb 19, 2009, at 4:33 PM, oberger wrote:
Thank you Michael,
but I am not able to bring this to work. Even with a flush and a
commit after every Statement.
I understand the problem with dependend UPDATES/DELETES.
But how is the ordering_list suposed to work?
Hi,
There are two styles of writing code for querying: the assignmapper
style, i.e. Class.query vs. the standard style as documented in
SQLAlchemy tutorial, i.e. DBSession.query(Class).
The assignmapper style seems simpler and intuitive. Curious to know
why it is not the standard way. Are there
17 matches
Mail list logo