[sqlalchemy] could not assemble any primary key columns for mapped table '...'

2010-05-20 Thread Yang Zhang
= Column(SmallInteger) x = Column(SmallInteger) Thanks for any hints. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group

[sqlalchemy] Custom UUID type with variant impl

2010-05-20 Thread Yang Zhang
I defined a TypeDecorator with impl=postgres.PGUuid so that I can work with raw UUID bytes (instead of hex strings), but I'd like to make this portable to other DBMSs, where i want the impl to be a BLOB. How can I do this? The reference docs are pretty sparse here. Thanks in advance. -- Yang

Re: [sqlalchemy] Custom UUID type with variant impl

2010-05-21 Thread Yang Zhang
On Thu, May 20, 2010 at 8:06 PM, Michael Bayer mike...@zzzcomputing.com wrote: On May 20, 2010, at 4:49 PM, Yang Zhang wrote: I defined a TypeDecorator with impl=postgres.PGUuid so that I can work with raw UUID bytes (instead of hex strings), but I'd like to make this portable to other DBMSs

Re: [sqlalchemy] could not assemble any primary key columns for mapped table '...'

2010-05-21 Thread Yang Zhang
On Thu, May 20, 2010 at 8:09 PM, Michael Bayer mike...@zzzcomputing.com wrote: On May 20, 2010, at 5:51 PM, Yang Zhang wrote: How do I create an ORM type with no primary key columns? For some reason I'm getting:  sqlalchemy.exc.ArgumentError: Mapper Mapper|ActorActivity|actor_activities

Re: [sqlalchemy] Custom UUID type with variant impl

2010-05-21 Thread Yang Zhang
wrote: On May 20, 2010, at 4:49 PM, Yang Zhang wrote: I defined a TypeDecorator with impl=postgres.PGUuid so that I can work with raw UUID bytes (instead of hex strings), but I'd like to make this portable to other DBMSs, where i want the impl to be a BLOB. How can I do this? The reference

[sqlalchemy] BLOB and str comparisons

2010-05-21 Thread Yang Zhang
awareness? Is there any way to avoid having to do this for every such query? Thanks in advance. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com

[sqlalchemy] Re: BLOB and str comparisons

2010-05-21 Thread Yang Zhang
On Fri, May 21, 2010 at 6:47 PM, Yang Zhang yanghates...@gmail.com wrote: I'm trying to run the following:  session.query(Activity).filter(Activity.blob == blob).one() where Activity.blob is a BLOB and blob is a Python bytes object (equiv. to str in Python 2.x). But although I can insert

Re: [sqlalchemy] Re: BLOB and str comparisons

2010-05-23 Thread Yang Zhang
On Sat, May 22, 2010 at 4:12 PM, Michael Bayer mike...@zzzcomputing.com wrote: On May 22, 2010, at 1:14 AM, Michael Bayer wrote: On May 21, 2010, at 10:04 PM, Yang Zhang wrote: Also, how do I do the wrapping portably? For sqlite3 I have to wrap with sqlite3.Binary, for postgresql I have

Re: [sqlalchemy] What is a good pattern for using sqlalchemy+psycopg2+gevent in a pylons app

2010-06-25 Thread Yang Zhang
this group at http://groups.google.com/group/sqlalchemy?hl=en. I would also love to know the answer to this question! Also interested in other libraries like those for mysql (gevent-mysql). -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google

[sqlalchemy] Getting ORM to use locking selects (select for update, etc.)

2010-06-25 Thread Yang Zhang
How do I get the ORM to use locking selects when I do a Session.query()? E.g., select for update, or select for share (PG)/select lock in share mode (MySQL). I know this is possible using the lower-level SQL expression library. Thanks in advance. -- Yang Zhang http://yz.mit.edu/ -- You

Re: [sqlalchemy] What is a good pattern for using sqlalchemy+psycopg2+gevent in a pylons app

2010-06-25 Thread Yang Zhang
/dvarrazzo/psycogreen/src/tip/gevent/psyco_gevent.py -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy

Re: [sqlalchemy] Getting ORM to use locking selects (select for update, etc.)

2010-06-25 Thread Yang Zhang
On Fri, Jun 25, 2010 at 6:42 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 25, 2010, at 3:27 AM, Yang Zhang wrote: How do I get the ORM to use locking selects when I do a Session.query()?  E.g., select for update, or select for share (PG)/select lock in share mode (MySQL).  I know

[sqlalchemy] ObjectDeletedError on orm.Query.delete

2010-07-01 Thread Yang Zhang
, blah.actor_id AS blah_actor_id, blah.domain AS blah_domain, ... FROM blah WHERE blah.id = ? sqlalchemy.engine.base.Engine.0x...1f90: INFO: (426,) sqlalchemy.engine.base.Engine.0x...1f90: INFO: ROLLBACK -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed

[sqlalchemy] Read-only transactions

2010-11-05 Thread Yang Zhang
? Some Googling turned up monkey-patching the .flush() method to be a no-op that also logs a message, but we're interested in raising an exception if the flush actually has dirty data to write. Thanks! -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed

Re: [sqlalchemy] Read-only transactions

2010-11-06 Thread Yang Zhang
read-write - but we'd like to avoid having to keep around for each web app thread multiple Sessions (and thus 2x the open connections on the DB). Yang On Fri, Nov 5, 2010 at 6:42 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 5, 2010, at 8:48 PM, Yang Zhang wrote: Hi, we're building

[sqlalchemy] Quick question on fetch batch size

2010-11-22 Thread Yang Zhang
When reading objects like so (notice no `.all()`): for obj in Session().query(User): ... what's the batch size with which sqlalchemy fetches rows from the DB? (If the engine matters: for Postgresql, MySQL, and sqlite?) Thanks. -- Yang Zhang http://yz.mit.edu/ -- You received

[sqlalchemy] Multi-get?

2011-01-26 Thread Yang Zhang
Is there something similar to the .get() method in SqlSoup and Session but which allows me to fetch more than one object by ID, so as to save on round trips to the DB? (This could be done by composing using the IN operator in SQL.) Thanks in advance. -- Yang Zhang http://yz.mit.edu/ -- You

Re: [sqlalchemy] Multi-get?

2011-01-27 Thread Yang Zhang
Yeah, that's what we do right now. On Wed, Jan 26, 2011 at 8:03 PM, Mike Conley mconl...@gmail.com wrote: On Wed, Jan 26, 2011 at 8:17 PM, Yang Zhang yanghates...@gmail.com wrote: Is there something similar to the .get() method in SqlSoup and Session but which allows me to fetch more than

[sqlalchemy] Advice on debugging an unexpected dirty flush update

2011-03-09 Thread Yang Zhang
I have a model with a field: class Obj(Base): ... meta = Column(PickleType) For some reason, when I do obj = session.query(Obj).get(id) obj2 = session.query(Obj2) I get a dirty UPDATE being attempted on the first object (noticed this due to read-only access to a Postgresql DB):

Re: [sqlalchemy] Advice on debugging an unexpected dirty flush update

2011-03-09 Thread Yang Zhang
On Wed, Mar 9, 2011 at 7:46 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 9, 2011, at 4:57 AM, Yang Zhang wrote: I have a model with a field: class Obj(Base):  ...  meta = Column(PickleType) For some reason, when I do  obj = session.query(Obj).get(id)  obj2 = session.query

Re: [sqlalchemy] Advice on debugging an unexpected dirty flush update

2011-03-09 Thread Yang Zhang
On Wed, Mar 9, 2011 at 12:07 PM, Yang Zhang yanghates...@gmail.com wrote: On Wed, Mar 9, 2011 at 7:46 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 9, 2011, at 4:57 AM, Yang Zhang wrote: I have a model with a field: class Obj(Base):  ...  meta = Column(PickleType) For some

[sqlalchemy] ORM performance

2011-04-13 Thread Yang Zhang
, and we can't help but feel that we might be doing something wrong or missing something obvious. We're wondering if there are any tips or anything built in to SA that could help improve the performance situation. Thanks! -- Yang Zhang http://yz.mit.edu/ -- You received this message because

[sqlalchemy] Postgresql COPY

2011-04-15 Thread Yang Zhang
, but that didn't work. Thanks in advance. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr

Re: [sqlalchemy] ORM performance

2011-04-26 Thread Yang Zhang
this is such a frequently used construct. But we wanted to see if we're missing anything first. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe

Re: [sqlalchemy] ORM performance

2011-04-26 Thread Yang Zhang
On Tue, Apr 26, 2011 at 12:32 PM, Yang Zhang yanghates...@gmail.com wrote: On Wed, Apr 13, 2011 at 6:07 PM, Michael Bayer mike...@zzzcomputing.com wrote: To work around the instance arguments being baked in, create the query like this: query.filter(SomeClass.somerecord ==bindparam

[sqlalchemy] Query object over sqlite3 returning Nones

2011-11-18 Thread Yang Zhang
, nullable=False) time = Column(DateTime, nullable=False) Short of dumping my entire DB, any hints as to what might cause `None` to be returned? I searched the documentation but couldn't find any leads. Thanks. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you

[sqlalchemy] Re: Query object over sqlite3 returning Nones

2011-11-18 Thread Yang Zhang
mention of this peculiar distinguishing behavior. Anyway, that's that. On Fri, Nov 18, 2011 at 4:45 PM, Yang Zhang yanghates...@gmail.com wrote: I'm using sqlalchemy 0.6.6 and sqlite 3.6.22 on Python 2.6.  When I do:    In [1]: for i in ses.query(UserSnapshot):       ...:     print i

[sqlalchemy] AttributeError: 'Session' object has no attribute '_model_changes'

2013-10-22 Thread Yang Zhang
Specifically, the code path where this is appearing ends up looking like: session = sqlalchemy.orm.Session(sqlalchemy.create_engine('sqlite:///')) session.execute('run_some_transaction()') session.commit() This raises: AttributeError: 'Session' object has no attribute '_model_changes' I get

[sqlalchemy] Re: AttributeError: 'Session' object has no attribute '_model_changes'

2013-10-22 Thread Yang Zhang
Sorry, disregard—wrong mailing list! This is Flask-SQLAlchemy-specific. On Mon, Oct 21, 2013 at 11:51 PM, Yang Zhang yanghates...@gmail.com wrote: Specifically, the code path where this is appearing ends up looking like: session = sqlalchemy.orm.Session(sqlalchemy.create_engine('sqlite

[sqlalchemy] Connecting via pyodbc (to Vertica)

2013-11-08 Thread Yang Zhang
I'm trying to connect to Vertica as a regular ODBC DSN, which I can do fine outside of sqlalchemy: $ isql -v pod +---+ | Connected!| | | | sql-statement | | help

[sqlalchemy] Re: Connecting via pyodbc (to Vertica)

2013-11-08 Thread Yang Zhang
Right after sending this, I hit upon the magic incantation, which I had not thought of trying: vertica+pyodbc://pod Sigh. On Fri, Nov 8, 2013 at 4:48 PM, Yang Zhang yanghates...@gmail.com wrote: I'm trying to connect to Vertica as a regular ODBC DSN, which I can do fine outside of sqlalchemy