[sqlalchemy] object dirtiness from the session's perspective?

2010-07-08 Thread Chris Withers
Hi All, I'm working on a variation of this recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/VersionedRows ...and I've got a couple of questions about changed objects: - do objects end up in session.dirty as a result of attributes being set or changed? For example: class

Re: [sqlalchemy] blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Chris Withers
zende wrote: Base.metadata.drop_all() completely blocks in the tearDown method of some of my tests. What database backend are you using *in the tests*? Where is the code blocking? (ie: when you hit ctrl-c, you should get a traceback, it would be handy to see that...) cheers, Chris --

Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
Oliver Beattie wrote: @property def is_visible(self): return (self.enabled and not self.is_deleted) This can clearly be mapped quite easily to SQL expression `Klass.enabled == True Klass.is_deleted == False` You could always add a class-level attribute that stored this...

Re: [sqlalchemy] Using the declarative base across projects

2010-07-08 Thread Chris Withers
thatsanicehatyouh...@mac.com wrote: This is a bit tricky to explain. Imagine I have one database, and I create a project (1) to work with that database (connections, table class definitions, etc.). That is standalone (to me). I have another completely separate database (2) on another host

Re: [sqlalchemy] problems with multi-table mapping on IronPython

2010-07-08 Thread Harry Percival
Here's the source code of my test - let me know if I'm doing anything wrong here from sqlalchemy import create_engine from sqlalchemy.orm import mapper from sqlalchemy.sql.expression import join from sqlalchemy.orm.session import sessionmaker from sqlalchemy.schema import MetaData import

RE: [sqlalchemy] Using the declarative base across projects

2010-07-08 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of thatsanicehatyouh...@mac.com Sent: 07 July 2010 20:33 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Using the declarative base across projects Hi Lance, Thanks

RE: [sqlalchemy] Comparable properties

2010-07-08 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Chris Withers Sent: 08 July 2010 09:28 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Comparable properties Oliver Beattie wrote: @property def

Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
King Simon-NFHD78 wrote: @hybrid def is_visible(self): return (self.enabled == True) (self.is_deleted == False) Yeah, having to write something that works as both plain python and a sql layer construct seems a little brittle. I wonder if a decorator could be knocked up which would

[sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Hi All, I'm a bit surprised to find that you have to ask for the new C extensions in 0.6 to be explicitly compiled. It also appears that the way of requesting this isn't compatible with build tools like a pip requirements file or buildout. What was the reason for that? If it was purely in

[sqlalchemy] docs for History object?

2010-07-08 Thread Chris Withers
Hi All, Where can I find documentation of the History objects used by the orm layer? In particular, how come each of .added, .unchanged and .deleted is a sequence? Are history objects always around or is there a performance hit for using them? cheers, Chris -- You received this message

[sqlalchemy] make_transient vs expunge

2010-07-08 Thread Chris Withers
Hi All, My flow of questions continues ;-) What's the difference beween make_transient(instance), where I guess make_transient comes from sqlalchemy.org, and session.expunge(instance)? cheers, Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy

Re: [sqlalchemy] make_transient vs expunge (correction)

2010-07-08 Thread Chris Withers
Chris Withers wrote: Hi All, My flow of questions continues ;-) What's the difference beween make_transient(instance), where I guess make_transient comes from sqlalchemy.org, ...er, that's sqlachemy.orm... Chris -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] Class defining time significance

2010-07-08 Thread Craig Macomber
''' For some reason, when I define my class seems to impact sqlalchemy Below is code where if the class Formation(Library): pass line is moved down, it works, but as is, I get the error at the end of this file, raised when the last line runs This seems very odd (and bug like) to me, and I'm

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Michael Bayer
On Jul 8, 2010, at 6:30 AM, Chris Withers wrote: Hi All, I'm a bit surprised to find that you have to ask for the new C extensions in 0.6 to be explicitly compiled. It also appears that the way of requesting this isn't compatible with build tools like a pip requirements file or

Re: [sqlalchemy] object dirtiness from the session's perspective?

2010-07-08 Thread Lance Edgar
On 7/8/2010 3:23 AM, Chris Withers wrote: Hi All, I'm working on a variation of this recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/VersionedRows ...and I've got a couple of questions about changed objects: - do objects end up in session.dirty as a result of attributes being set

Re: [sqlalchemy] Class defining time significance

2010-07-08 Thread Michael Bayer
On Jul 7, 2010, at 10:52 PM, Craig Macomber wrote: ''' For some reason, when I define my class seems to impact sqlalchemy Below is code where if the class Formation(Library): pass line is moved down, it works, but as is, I get the error at the end of this file, raised when the last line

Re: [sqlalchemy] object dirtiness from the session's perspective?

2010-07-08 Thread Chris Withers
Lance Edgar wrote: - do objects end up in session.dirty as a result of attributes being set or changed? Setting an attribute is enough for the instance to wind up in Session.dirty, according to http://www.sqlalchemy.org/docs/reference/orm/sessions.html#sqlalchemy.orm.session.Session.dirty

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Michael Bayer wrote: http://svn.zope.org/zope.interface/trunk/setup.py?view=auto we wanted to annoy buildout/setuptools/Glyph as much as possible, and I am happy to say we succeeded. I hope you're joking :-S The issue of them not building by default wasn't that they might not build, just

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Michael Bayer
On Jul 8, 2010, at 10:43 AM, Chris Withers wrote: Michael Bayer wrote: http://svn.zope.org/zope.interface/trunk/setup.py?view=auto we wanted to annoy buildout/setuptools/Glyph as much as possible, and I am happy to say we succeeded. I hope you're joking :-S The issue of them not

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Michael Bayer wrote: Not sure if we'd want to change this default midway through 0.6 or wait til 0.7. Fair enough, but this is sadly one of those things where you're only likely to find the edge cases when you do make it on by default... The C exts also don't improve performance that much

[sqlalchemy] Re: Class defining time significance

2010-07-08 Thread Craig Macomber
Thank you. I was hoping it was something like that as I couldn't see anything else that would make sense. On Jul 8, 6:52 am, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 7, 2010, at 10:52 PM, Craig Macomber wrote: ''' For some reason, when I define my class seems to impact

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Mariano Mara
Excerpts from zende's message of Thu Jul 08 13:27:27 -0300 2010: I reproduced the issue the script below: http://gist.github.com/468199 Sorry for the weak explanation before. This has little to do with being in tests except that's the only code that drops and creates the db for any reason.

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
Mariano, What db? postgres? On Jul 8, 9:41 am, Mariano Mara mariano.m...@gmail.com wrote: I'm on a similar situation. For lack of time I couldn't investigate it yet but I have a drop_all when running nosetests in my pylons project and it get stuck while dropping the tables. I have to kill the

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread jason kirtland
Your scoped session still has an active connection, which is blocking the drop. Call session.remove() before the drop, or configure the session with expires_on_commit=False to not issue SELECTs to fetch object state after the final commit(). On Thu, Jul 8, 2010 at 9:27 AM, zende

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Mariano Mara
Excerpts from zende's message of Thu Jul 08 14:01:32 -0300 2010: Mariano, What db? postgres? On Jul 8, 9:41 am, Mariano Mara mariano.m...@gmail.com wrote: I'm on a similar situation. For lack of time I couldn't investigate it yet but I have a drop_all when running nosetests in my pylons

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
Jason, in the contrived example I came up with and posted, your solution worked but not in my tests. I tried both expires_on_commit=False and Session.remove() before the drop with no luck. Thanks for the suggestion On Jul 8, 10:03 am, jason kirtland j...@discorporate.us wrote: Your scoped

[sqlalchemy] Re: WITH ... SELECT queries in postgres

2010-07-08 Thread Mike Lewis
I'd be interested in prototyping a WithClause or something similar if you think it might be useful. I imagine it would have similar semantics to a FromClause but would be prepended to the query. Currently, I'm not too interested in prototyping the RECURSIVE part and only care about Postgres.

[sqlalchemy] mapping objects to arbitary selects, read and write

2010-07-08 Thread Chris Withers
Hi All, Say we have the following model: class Price(Base): __tablename__ = 'price' id = Column(Integer, primary_key=True) value = Column(Numeric(precision=36, scale=12)) class Instrument(Base): __tablename__ = 'instrument' id = Column(Integer, primary_key=True) ticker

Re: [sqlalchemy] Re: WITH ... SELECT queries in postgres

2010-07-08 Thread Michael Bayer
I'd really be interested in defining a system that covers WITH / RECURSIVE entirely, and makes sense both with PG / SQL server as well as Oracle.The work here is figuring out what is common about those two approaches and what an API that is meaningful for both would look like.

Re: [sqlalchemy] Composite column with a relationship

2010-07-08 Thread Michael Bayer
On Jul 7, 2010, at 3:19 PM, Nikolaj wrote: Hi there, I'd like to create a column composite for amounts of money and their currency. However, the difficulty comes in keeping the currencies in a separate table and enabling my composite to find this relationship. Is there some way to set

Re: [sqlalchemy] mapping objects to arbitary selects, read and write

2010-07-08 Thread Michael Bayer
On Jul 8, 2010, at 2:42 PM, Chris Withers wrote: Hi All, Say we have the following model: class Price(Base): __tablename__ = 'price' id = Column(Integer, primary_key=True) value = Column(Numeric(precision=36, scale=12)) class Instrument(Base): __tablename__ =

[sqlalchemy] Re: WITH ... SELECT queries in postgres

2010-07-08 Thread Mike Lewis
That's a fair point. I think one interface might be casting a FromClause into a WithClause similar to how one would alias something. With postgres it seams like when going from a WITH to WITH recursive is adding a UNION ALL and the recursive term. Throwing out an idea for an interface (for

[sqlalchemy] Re: WITH ... SELECT queries in postgres

2010-07-08 Thread Mike Lewis
Sorry, google groups formatted that *really* poorly. On Jul 8, 12:28 pm, Mike Lewis mikelikes...@gmail.com wrote: That's a fair point. I think one interface might be casting a FromClause into a WithClause similar to how one would alias something. With postgres it seams like when going from

Re: [sqlalchemy] Re: WITH ... SELECT queries in postgres

2010-07-08 Thread Michael Bayer
On Jul 8, 2010, at 3:28 PM, Mike Lewis wrote: That's a fair point. I think one interface might be casting a FromClause into a WithClause similar to how one would alias something. With postgres it seams like when going from a WITH to WITH recursive is adding a UNION ALL and the recursive

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
nope. Jason was right :D. I needed to add Session.remove() to my threads as well; though, I'm not sure why adding expires_on_commit=False alone didn't solve it. Oh well, works now Thanks! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

Re: [sqlalchemy] mapping objects to arbitary selects, read and write

2010-07-08 Thread Chris Withers
Michael Bayer wrote: class Allocation(Base): __tablename__ = 'data' id = Column(Integer, primary_key=True) trade_id = Column(Integer, index=True) instrument_id = Column(ForeignKey(Instrument.id)) instrument = relationship(Instrument) quantity = Column(Integer) price_id =

[sqlalchemy] negative implications of using multiple declarative Base classes

2010-07-08 Thread Randy Syring
I have been, naively it seems, using multiple declarative Base classes in my webapp. They all share the same metadata object. I have found one negative ramification of this, which is that string references (like what can be used in relation()) won't find the object if they are not using the same

[sqlalchemy] Re: negative implications of using multiple declarative Base classes

2010-07-08 Thread avdd
I'm glad you brought this up. It seems to me that the the declarative instrumentation keys classes by their unqualified class name, precluding using the same class name for different declarative subclasses (ie, in different modules). On Jul 9, 12:01 pm, Randy Syring ra...@rcs-comp.com wrote: