Re: [sqlalchemy] Custom Dialect - recommendations needed for handling of Sequences/lastrowid

2013-01-25 Thread Michael Bayer
On Jan 25, 2013, at 2:25 AM, jank wrote: Hello, I have implemented a dialect for a new database (EXASol). that's great. I'd like to point you to a new system we have for testing and deploying external dialects, where your dialect can be packaged with a standard layout and make use of a

[sqlalchemy] Explicit locking

2013-01-25 Thread Philip Goh
Hello, I have multiple processes that can potentially insert duplicate rows into the database. These inserts do not happen very frequently (a few times every hour) so it is not performance critical. I've tried an exist check before doing the insert, like so: #Assume we're inserting a camera

[sqlalchemy] Can't access model object backref

2013-01-25 Thread sector119
Hello. I have Category model: class Category(Base): __tablename__ = 'categories' id = Column(Integer, primary_key=True) parent_id = Column(Integer, ForeignKey('categories.id')) name = Column(Unicode(255), nullable=False) description = Column(UnicodeText) position =

[sqlalchemy] Re: Can't access model object backref

2013-01-25 Thread sector119
I want to order_by(Category.parent.name, Category.name) is it possible? -- 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

Re: [sqlalchemy] Re: Can't access model object backref

2013-01-25 Thread Michael Bayer
You need to join to Category.parent first. It also must be aliased, because this is self-referential: ca = aliased(Category) query(Category).join(ca, Category.parent).order_by(ca.name, Category.name) On Jan 25, 2013, at 3:49 PM, sector119 wrote: I want to order_by(Category.parent.name,

[sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Pedro Werneck
I'm having a problem with many concurrent scripts, workers and uwsgi instances writing and reading the same tables and rows almost simultaneously, and sometimes one of them seems to get an older state, even from an object it never touched in the first place and I'm querying for the first time.

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Michael Bayer
On Jan 25, 2013, at 4:33 PM, Pedro Werneck wrote: I'm having a problem with many concurrent scripts, workers and uwsgi instances writing and reading the same tables and rows almost simultaneously, and sometimes one of them seems to get an older state, even from an object it never touched

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Pedro Werneck
Well... I'm afraid it's not as simple as that. I'll give an example: I have a webservice A, which triggers a callback and calls webservice B, creating a new row in the database with status = 0 and commiting the transaction. Then I have a script which finds all rows with status = 0, and sends

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Michael Bayer
On Jan 25, 2013, at 5:12 PM, Pedro Werneck wrote: Well... I'm afraid it's not as simple as that. I'll give an example: I have a webservice A, which triggers a callback and calls webservice B, creating a new row in the database with status = 0 and commiting the transaction. Then I have

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Michael Bayer
On Jan 25, 2013, at 5:35 PM, Pedro Werneck wrote: If the script that is searching for status=0 is finding rows that are committed, then the worker that is querying for those rows should be able to see them, unless the worker has been holding open a long running transaction. Exactly.

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Pedro Werneck
That works, but now I'll have to change how my models use the session. Would this all be solved if I just use READ COMMITTED transaction isolation? On Fri, Jan 25, 2013 at 8:45 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Jan 25, 2013, at 5:35 PM, Pedro Werneck wrote: If the script

Re: [sqlalchemy] Refresh session: rollback() or commit()?

2013-01-25 Thread Michael Bayer
On Jan 25, 2013, at 8:02 PM, Pedro Werneck wrote: That works, but now I'll have to change how my models use the session. hmm, is that because your model objects themselves are controlling the scope of the transaction ?That's another pattern I don't really recommend... Would this all