Re: [sqlalchemy] Re: How to stop SQLAlchemy from adding an ON UPDATE clause to a TIMESTAMP column by default

2014-01-10 Thread Steve Johnson
My solution, since sqlalchemy seems to be ignoring the nullable and default kwargs, is this: time = Column( TIMESTAMP(), primary_key=True, server_default=text("'-00-00 00:00:00'")) The default is just never used. On Friday, January 10, 2014 12:20:45 PM UTC-8, Steve Johns

Re: [sqlalchemy] Re: How to stop SQLAlchemy from adding an ON UPDATE clause to a TIMESTAMP column by default

2014-01-10 Thread Steve Johnson
I realize this thread is ancient, but I'm resurrecting it for Googleable posterity since I just ran across the same issue. The problem is that MySQL "helpfully" inserts the ON UPDATE cheese unless you specify a default and/or a NULL/NOT NULL value in the CREATE TABLE query. http://dev.mysql.co

Re: [sqlalchemy] Custom logic for query execution

2014-01-10 Thread Sylvester Steele
Thanks for you feedback. I will take a look at the pessimistic listener On Fri, Jan 10, 2014 at 2:02 PM, Michael Bayer wrote: > > On Jan 10, 2014, at 1:50 PM, Sylvester Steele > wrote: > > Hi, > Currently I am using the sqlalchemy engine to execute string queries only. > I do plan on using sqla

Re: [sqlalchemy] Custom logic for query execution

2014-01-10 Thread Claudio Freire
On Fri, Jan 10, 2014 at 3:50 PM, Sylvester Steele wrote: > Hi, > Currently I am using the sqlalchemy engine to execute string queries only. I > do plan on using sqlalchemy more extensively (including ORM) in the near > future. > I need to add retry logic on every query, in case of some database fa

Re: [sqlalchemy] Custom logic for query execution

2014-01-10 Thread Michael Bayer
On Jan 10, 2014, at 1:50 PM, Sylvester Steele wrote: > Hi, > Currently I am using the sqlalchemy engine to execute string queries only. I > do plan on using sqlalchemy more extensively (including ORM) in the near > future. > I need to add retry logic on every query, in case of some database f

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Michael Bayer
On Jan 10, 2014, at 1:42 PM, Paul Moore wrote: > On Friday, 10 January 2014 17:52:45 UTC, Michael Bayer wrote: > there’s various patterns for dealing with the very common issue of “create > unique object if not exists, else use the current one”. One that I > frequently point to is the unique

[sqlalchemy] Custom logic for query execution

2014-01-10 Thread Sylvester Steele
Hi, Currently I am using the sqlalchemy engine to execute string queries only. I do plan on using sqlalchemy more extensively (including ORM) in the near future. I need to add retry logic on every query, in case of some database failures (less than ideal, but the server is a bit flaky). Quest

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
On Friday, 10 January 2014 17:52:45 UTC, Michael Bayer wrote: > > there’s various patterns for dealing with the very common issue of “create > unique object if not exists, else use the current one”. One that I > frequently point to is the unique object recipe: > OK, so looking at that seems to

Re: [sqlalchemy] SQLAlchemy not executing query

2014-01-10 Thread Sylvester Steele
Thank you that worked. On Thu, Jan 9, 2014 at 7:47 PM, Michael Bayer wrote: > The statement is likely being invoked but is in a transaction that isn’t > getting committed (assuming you’re using commit() with pyodbc). > SQLAlchemy has an “autocommit” feature that by default looks for SQL > string

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Michael Bayer
On Jan 10, 2014, at 8:44 AM, Paul Moore wrote: > > So far, so good. But if I want to create a new Release, things get messy. > This is my basic function: > > def new_release(package, version, data): > r = Release(version) > r.package = Package(package) > # Populate the data in r,

Re: [sqlalchemy] Why ORM objects in a session expire immediately after a failure in flush?

2014-01-10 Thread Michael Bayer
changelog in 0.8.0b1: http://docs.sqlalchemy.org/en/rel_0_9/changelog/changelog_08.html#change-1df6e3552ee895cd48952f95c0f0730a ticket: http://www.sqlalchemy.org/trac/ticket/2452 I wonder if offering that the automatic rollback() on flush() might be optionally disabled (which means, a corrupte

Re: [sqlalchemy] Polymorphic joined-table inheritance

2014-01-10 Thread Michael Bayer
On Jan 10, 2014, at 7:08 AM, david.ceresu...@gmail.com wrote:Problem: Querying client and clientvip---With this code I try to query all the clients [ clients = DBSession.query(Client) ]and this is where the problems start, because the query it is

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
(Dashing off a quick reply, as I'm on my way out - I'll have a proper read and think about your message later. Thanks!) On Friday, 10 January 2014 17:22:35 UTC, Kevin H wrote: > I don't think it has to be committed yet, it just has to exist in the > session. See below. > That's really good

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Kevin Horn
On Fri, Jan 10, 2014 at 10:55 AM, Paul Moore wrote: > On Friday, 10 January 2014 16:27:12 UTC, Kevin H wrote: > >> It sounds to me like the problem you're having has to do with how you are >> getting the reference to the package, which isn't shown in your example. >> How are you getting it? >> >

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
On Friday, 10 January 2014 16:27:12 UTC, Kevin H wrote: > It sounds to me like the problem you're having has to do with how you are > getting the reference to the package, which isn't shown in your example. > How are you getting it? > The new_release() function is what I do - I create a new Pa

Re: [sqlalchemy] Polymorphic joined-table inheritance

2014-01-10 Thread Kevin Horn
I'm not really sure, but you probably need to be calling super() somewhere in Client.__init__, which you don't seem to be doing. The main difference between your code and what I would usually do is that I almost never override __init__ in my models. I expect some of the setup for inheritance happ

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Kevin Horn
It sounds to me like the problem you're having has to do with how you are getting the reference to the package, which isn't shown in your example. How are you getting it? The session doesn't do anything "by magic", even if it seems that way sometimes. It just manages things behind the scenes. I

Re: [sqlalchemy] Anybody have twophase/zope.sqlalchemy/MySQL working?

2014-01-10 Thread Michael Bayer
On Jan 10, 2014, at 3:32 AM, Laurence Rowe wrote: > > On Thursday, 9 January 2014 09:41:40 UTC-8, Jeff Dairiki wrote: > Okay, I've traced things out a bit more. > > If the session state is not STATUS_INVALIDATED (aka STATUS_CHANGED), > SessionDataManager.commit() does a self._finish('no work

[sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
I'm developing an application using the ORM, and I am getting into all sorts of trouble with what I think should be a pretty simple data model. I've tried following the ORM tutorial from the docs, but it seems to get me confused every time I try. So I'm looking for something else that maybe tak

Re: [sqlalchemy] Why ORM objects in a session expire immediately after a failure in flush?

2014-01-10 Thread Claudio Freire
On Thu, Jan 9, 2014 at 9:59 PM, Michael Bayer wrote: > I do notice that you’re catching an IntegrityError.The typical pattern > when writing code that wants to catch these and then continue is to run the > individual set of questionable operations within a SAVEPOINT, that is a > begin_nested()

[sqlalchemy] Polymorphic joined-table inheritance

2014-01-10 Thread david . ceresuela
Hello all, I'm trying to use SQLAlchemy inheritance in a (company's) project and I cannot seem to make it work. First, the versions: - Ubuntu: 12.10 - Python: 2.7.3 - SQLAlchemy: 0.9.1 - PostgreSQL: 9.1 - sqlite: 3.7.13 - Pyramid: 1.4.2 All of the problems happen in both PostgreSQL and sqlite.

Re: [sqlalchemy] Multiple inheritance issue

2014-01-10 Thread Enrico Bottani
Thank you very much MichaeI was in fact thinking that it was possible to not found support for that feature. But as you said, the compiler didn't shout at me and the application was running fine so I was thinking that I was doing things right. I'll go for the JOIN. Best, Enrico On Thursday,

Re: [sqlalchemy] Anybody have twophase/zope.sqlalchemy/MySQL working?

2014-01-10 Thread Laurence Rowe
On Thursday, 9 January 2014 09:41:40 UTC-8, Jeff Dairiki wrote: > > Okay, I've traced things out a bit more. > > If the session state is not STATUS_INVALIDATED (aka STATUS_CHANGED), > SessionDataManager.commit() does a self._finish('no work'). That is > where self.tx gets set to None (this ---