Re: [sqlalchemy] get to dialect specific column type

2010-09-22 Thread werner
I tried with a hack to get to this, but still no luck. I am doing: from sqlalchemy.dialects.firebird import dialect ... fbDialect = dialect() ... if str(col.type) == 'DATETIME': print col.type.dialect_impl(fbDialect) print col.type.get_dbapi_type(fbDialect)

[sqlalchemy] declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Yap Sok Ann
This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9d2ab0b9cca Prior to version 0.6, I use the following code to automatically add a primary key if the table doesn't have one defined: from sqlalchemy.ext.declarative

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Bayer
On Sep 21, 2010, at 11:51 PM, Michael Hipp wrote: On 9/21/2010 8:17 PM, Michael Bayer wrote: It definitely does not attempt an INSERT if id_ is set to a non-None value, assuming that row already exists in the DB, without something else in your model/usage causing that to happen.If id_

Re: [sqlalchemy] declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 4:30 AM, Yap Sok Ann wrote: This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9d2ab0b9cca Prior to version 0.6, I use the following code to automatically add a primary key if the table

Re: [sqlalchemy] get to dialect specific column type

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 3:06 AM, werner wrote: I tried with a hack to get to this, but still no luck. I am doing: from sqlalchemy.dialects.firebird import dialect ... fbDialect = dialect() ... if str(col.type) == 'DATETIME': print col.type.dialect_impl(fbDialect)

Re: [sqlalchemy] get to dialect specific column type

2010-09-22 Thread werner
I try to explain in more detail what I am trying to do. class Country(Base, CreateUpdateMixin): __tablename__ = u'countries' id = sa.Column(sa.BigInteger(), sa.Sequence('countries_id'), primary_key=True, nullable=False) name = sa.Column(sa.String(length=30,

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Hipp
On 9/22/2010 10:27 AM, Michael Bayer wrote: Michael, thanks so much for taking the time to compose a very thorough answer. If you could indulge a few clarifications/suggestions ... So here, the value of None for car.auction, merges into the session which becomes a pending change. The

Re: [sqlalchemy] get to dialect specific column type

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 12:19 PM, werner wrote: Witin make_localize_view I need to generate a stored procedure which gets information such as columns etc from Country and Country_L , the generated code looks like this: CREATE OR ALTER PROCEDURE countries_lp returns (created_at DATE,

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 12:21 PM, Michael Hipp wrote: On that last note I found that if I do: new = Car() new.id_ = old.id_ new = sess.merge(new) new.auction = old.auction # do this *after* merge sess.commit() This seems to work and avoids me having to deal with the cascade stuff (which

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Bayer
here's your new section: http://www.sqlalchemy.org/docs/orm/session.html#merge-tips -- 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

Re: [sqlalchemy] Change echo at will

2010-09-22 Thread Michael Hipp
On 8/26/2010 8:55 PM, Mike Conley wrote: On Thu, Aug 26, 2010 at 4:21 PM, Michael Hipp mich...@hipp.com mailto:mich...@hipp.com wrote: Is there a way to set 'echo' at any time? Everything I can find sets it when the engine is created and doesn't seem to change it afterward. You can

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Hipp
On 9/22/2010 11:21 AM, Michael Hipp wrote: new = Car() new.id_ = old.id_ new = sess.merge(new) new.auction = old.auction # do this *after* merge sess.commit() This seems to work and ... Bah. I spoke too soon - it just doesn't throw an exception. But without explicitly setting

Re: [sqlalchemy] Change echo at will

2010-09-22 Thread Michael Bayer
the logging level is checked on each new connection, so yes you can set echo at any time. On Sep 22, 2010, at 4:46 PM, Michael Hipp wrote: On 8/26/2010 8:55 PM, Mike Conley wrote: On Thu, Aug 26, 2010 at 4:21 PM, Michael Hipp mich...@hipp.com mailto:mich...@hipp.com wrote: Is there a

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 5:17 PM, Michael Hipp wrote: On 9/22/2010 11:21 AM, Michael Hipp wrote: new = Car() new.id_ = old.id_ new = sess.merge(new) new.auction = old.auction # do this *after* merge sess.commit() This seems to work and ... Bah. I spoke too soon - it just doesn't

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Hipp
On 9/22/2010 5:24 PM, Michael Bayer wrote: Here's the problem. The term a blank record is meaningless. Well, no, it's not. It's exactly what I get when I do new=Item() and commit(). It's very well defined, precise, and repeatable. Trying to make other tools guess this for you seems to be

Re: [sqlalchemy] Empty a record

2010-09-22 Thread Michael Bayer
On Sep 22, 2010, at 6:44 PM, Michael Hipp wrote: On 9/22/2010 5:24 PM, Michael Bayer wrote: Here's the problem. The term a blank record is meaningless. Well, no, it's not. It's exactly what I get when I do new=Item() and commit(). It's very well defined, precise, and repeatable.

[sqlalchemy] Re: declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Yap Sok Ann
On Sep 22, 11:37 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 22, 2010, at 4:30 AM, Yap Sok Ann wrote: This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9... Prior to version 0.6, I use the