[sqlalchemy] alchemy-migrate with DeclarativeBase

2010-06-16 Thread Shane
Hi , I am testing sqlalchemy-migrate with a DB revision script that adds a table to my database. Two questions here, but first system info: TG2 Framework (tg.devtools 2.0.2) with sqlalchemy_migrate-0.5.2-py2.6.egg MySQL 5.1.41 sqlalchemy V0.5.1 OS X 10.6.4 1) How do I use DeclarativeBase when d

[sqlalchemy] Re: Enforcing a single instance of an object, get_or_create() ?

2010-06-16 Thread Adam
The most logical place would seem to be the database - create a unique constraint on the 'name' column, or even make the name column the primary key rather than the integer ID. On Jun 16, 12:29 pm, Rich wrote: > Two part question... I have a table of activity types . I want to > follow a ‘singlet

[sqlalchemy] Enforcing a single instance of an object, get_or_create() ?

2010-06-16 Thread Rich
Two part question... I have a table of activity types . I want to follow a ‘singleton pattern’ (ie. Only one instance of ‘run’,’jump’,’swim’ etc.). I have a get_or_create function on the class that works as long as programmers using my module call: session.add( ActivityType.get_or_create(‘fly’))

[sqlalchemy] Re: deepcopy on a sequenced column

2010-06-16 Thread BearDeer
It worked! Thanks, this helped me a lot. On Jun 16, 10:36 am, Michael Bayer wrote: > I'd use column.copy() for this purpose. > > On Jun 16, 2010, at 10:32 AM, BearDeer wrote: > > > > > Hi guys, > > > In sqlalchemy 0.6.1, had a TypeError when trying to do: > > deepcopy(Column('id', Integer, Sequen

Re: [sqlalchemy] deepcopy on a sequenced column

2010-06-16 Thread Michael Bayer
I'd use column.copy() for this purpose. On Jun 16, 2010, at 10:32 AM, BearDeer wrote: > Hi guys, > > In sqlalchemy 0.6.1, had a TypeError when trying to do: > deepcopy(Column('id', Integer, Sequence('id_seq'), primary_key=True)). > But in 0.5.8 the above code works fine, could some one tell me

[sqlalchemy] deepcopy on a sequenced column

2010-06-16 Thread BearDeer
Hi guys, In sqlalchemy 0.6.1, had a TypeError when trying to do: deepcopy(Column('id', Integer, Sequence('id_seq'), primary_key=True)). But in 0.5.8 the above code works fine, could some one tell me what causes this error or how can I fix it? Thanks in advance. -- You received this message becau

[sqlalchemy] Re: session save

2010-06-16 Thread Aref
Is there a book that is more current that you recommend? Thanks On Jun 16, 7:35 am, Michael Bayer wrote: > unfortunately Essential SQLA is sorely out of date, save() was moved to add() > around the time of late 0.4 and in 0.6 we've removed the old save(). > > On Jun 16, 2010, at 9:31 AM, Aref w

[sqlalchemy] Re: session save

2010-06-16 Thread Aref
Thank you so much. I'll make a note of that. On Jun 16, 7:35 am, Michael Bayer wrote: > unfortunately Essential SQLA is sorely out of date, save() was moved to add() > around the time of late 0.4 and in 0.6 we've removed the old save(). > > On Jun 16, 2010, at 9:31 AM, Aref wrote: > > > > > Hell

Re: [sqlalchemy] Classmethods with Session and Declarative Syntax

2010-06-16 Thread Robert Sudwarts
Goddit !! Thank you so much!! On 16 June 2010 14:33, Michael Bayer wrote: > > On Jun 16, 2010, at 7:58 AM, Robert Sudwarts wrote: > > Hi, > > I'm having difficulty understanding how to call/create a session to access > a "class method" of a declaratively defined table/object: essentially my >

Re: [sqlalchemy] session save

2010-06-16 Thread Michael Bayer
unfortunately Essential SQLA is sorely out of date, save() was moved to add() around the time of late 0.4 and in 0.6 we've removed the old save(). On Jun 16, 2010, at 9:31 AM, Aref wrote: > Hello, > I am learning sqlalchemy and been reading and working through the > examples/tutorials in Copelan

Re: [sqlalchemy] Classmethods with Session and Declarative Syntax

2010-06-16 Thread Michael Bayer
On Jun 16, 2010, at 7:58 AM, Robert Sudwarts wrote: > Hi, > > I'm having difficulty understanding how to call/create a session to access a > "class method" of a declaratively defined table/object: essentially my > understanding of how session works in this context is at fault... Clearly, > t

[sqlalchemy] session save

2010-06-16 Thread Aref
Hello, I am learning sqlalchemy and been reading and working through the examples/tutorials in Copeland's "Essential SQLAlchemy". I am running sqlalchemy 0.6.1 and python2.5 I am running into a problem when trying to save a session using save. session.save(newuser) for example. I get an error say

Re: [sqlalchemy] Unset order_by()

2010-06-16 Thread Michael Bayer
its not really provided right now, the same way saying query.filter(None) won't reset any existing WHERE criterion, or join(None) doesn't remove all joins. This issue has come up before. How is order_by() different ? On Jun 16, 2010, at 8:05 AM, Andi Albrecht wrote: > Hi, > > I'm a bit cu

Re: [sqlalchemy] Using update()

2010-06-16 Thread Francisco Souza
Hi :) Take a look at this sample: http://paste.pocoo.org/show/226056/ The update is performed in the line 42. update() is a query operation :) See official docs: http://www.sqlalchemy.org/docs/reference/orm/query.html#sqlalchemy.orm.query.Query.update Best regards, Francisco Souza Software deve

[sqlalchemy] Unset order_by()

2010-06-16 Thread Andi Albrecht
Hi, I'm a bit curious about how to unset an order_by in 0.6. query.order_by(None) should do it, but in sqlalchemy/orm/query.py in _no_select_modifiers() the notset value for the _order_by attribute is False. In turn, the order_by() method doesn't seem to accept False. What would be a proper way

[sqlalchemy] Classmethods with Session and Declarative Syntax

2010-06-16 Thread Robert Sudwarts
Hi, I'm having difficulty understanding how to call/create a session to access a "class method" of a declaratively defined table/object: essentially my understanding of how session works in this context is at fault... Clearly, the @classmethod requires a **session** (and I realise that: "declarat

[sqlalchemy] Re: Unexpected SessionTransaction behaviour

2010-06-16 Thread Vinay Sajip
On Jun 15, 6:59 pm, Michael Bayer wrote: > So no, calling gc.collect() is not necessary under normal circumstances, it > is only needed here to for the purposes of the method of testing. Ok, thanks. I've done some more digging and find that there *are* some references knocking around, but not su