Re: [sqlalchemy] Re: Read only property

2010-08-31 Thread Petr Kobalíček
Hi Mark, I think I badly described what I'm doing. My problem is that I need to update some columns atomically and I'm using stored procedures for that. I'm still learning the postgres so maybe I'm doing so complex things for so simple tasks. As a very short and simple example: RecordTable:

Re: [sqlalchemy] How to add a record to one-to-many relation using a single query?

2010-08-31 Thread Michael Bayer
On Aug 31, 2010, at 1:36 AM, Russell Warren wrote: I've been through the orm tutorial several times now and the employee- addresses one-to-many example is a good one. I'm stumped on one thing so far. Say I want to add a new address for a user where the user name is wendy. I only know her

[sqlalchemy] Re: How to add a record to one-to-many relation using a single query?

2010-08-31 Thread Russell Warren
On Aug 31, 10:33 am, Michael Bayer mike...@zzzcomputing.com wrote: It sounds like you're looking for INSERT from SELECT.   SQL certainly allows this and you can build SQLAlchemy expression constructs that are similar, there's a mini example

Re: [sqlalchemy] Re: How to add a record to one-to-many relation using a single query?

2010-08-31 Thread Michael Bayer
On Aug 31, 2010, at 11:40 AM, Russell Warren wrote: On Aug 31, 10:33 am, Michael Bayer mike...@zzzcomputing.com wrote: It sounds like you're looking for INSERT from SELECT. SQL certainly allows this and you can build SQLAlchemy expression constructs that are similar, there's a mini

[sqlalchemy] Relationship where relation is set by condition not present in table

2010-08-31 Thread cd34
I have 4 tables: users, jobs, job_items, job_progress class User(Base): __tablename__ = 'xxx_users' fb_uid = Column(mysql.MSBigInteger(20, unsigned=True), primary_key=True) class Job(Base): __tablename__ = 'xxx_jobs' job_id = Column(mysql.MSBigInteger(20, unsigned = True),

[sqlalchemy] Re: Relationship where relation is set by condition not present in table

2010-08-31 Thread cd34
That's what I thought about 10 minutes after posting. I thought there might be a trick in the DeclarativeBase declaration that I missed. Thanks for the quick reply. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

[sqlalchemy] how to write custom DDL class

2010-08-31 Thread Petr Kobalíček
Hi, I have problem to understand which way should be used to write custom DDL class. I'm generating some stored procedures for my tables. The procedures are very similar and I'd like to use some generic way. Now I'm nearly done, but I need some way how to extract some information from table to

[sqlalchemy] Re: how to write custom DDL class

2010-08-31 Thread Petr Kobalíček
I solved everything by overriding against() _DDL_MATCHER = re.compile(ur\$\{(_\w+)\:{0,1}([^\}]*)\}) class CustomDDL(DDL): def __init__(self, statement, on=None, context=None, bind=None): super(CustomDDL, self).__init__(statement, on, context, bind) def against(self, target): global

Re: [sqlalchemy] how to write custom DDL class

2010-08-31 Thread Michael Bayer
On Aug 31, 2010, at 8:15 PM, Petr Kobalíček wrote: Hi, I have problem to understand which way should be used to write custom DDL class. I'm generating some stored procedures for my tables. The procedures are very similar and I'd like to use some generic way. Now I'm nearly done, but I

Re: [sqlalchemy] Re: how to write custom DDL class

2010-08-31 Thread Michael Bayer
On Aug 31, 2010, at 8:51 PM, Petr Kobalíček wrote: I solved everything by overriding against() _DDL_MATCHER = re.compile(ur\$\{(_\w+)\:{0,1}([^\}]*)\}) class CustomDDL(DDL): def __init__(self, statement, on=None, context=None, bind=None): super(CustomDDL, self).__init__(statement,

Re: [sqlalchemy] Re: how to write custom DDL class

2010-08-31 Thread Petr Kobalíček
Hi Michael, many thanks for explanation. I considered what you wrote and now I'm making my own class as a callable and I'm going to use append_ddl_listener(). This means I don't need DDLElement and DDL. Best regards Petr -- You received this message because you are subscribed to the Google

[sqlalchemy] How to get a column type from a column instance

2010-08-31 Thread Petr Kobalíček
Hi devs, how to get column type from a column instance? Imagine following table: RecordTable = Table('t_record', metadata, Column('record_id', Integer, primary_key = True), Column('dep', Integer, default=None) ) I can get my column using: engine = engine_from_config({ sqlalchemy.url:

Re: [sqlalchemy] How to get a column type from a column instance

2010-08-31 Thread Michael Bayer
On Aug 31, 2010, at 9:29 PM, Petr Kobalíček wrote: Hi devs, how to get column type from a column instance? Imagine following table: RecordTable = Table('t_record', metadata, Column('record_id', Integer, primary_key = True), Column('dep', Integer, default=None) ) I can get my

Re: [sqlalchemy] How to get a column type from a column instance

2010-08-31 Thread Petr Kobalíček
Thanks again! You saved me really a lot of time. Best regards Petr Kobalicek -- 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

[sqlalchemy] Re: How to add a record to one-to-many relation using a single query?

2010-08-31 Thread Russell Warren
On Aug 31, 12:16 pm, Michael Bayer mike...@zzzcomputing.com wrote: However I forgot one other approach that's also overkill for the general case, but is more useful with the ORM, which is that you can embed subqueries and other expressions into a flush. I usually use it with UPDATE

[sqlalchemy] Re: How to add a record to one-to-many relation using a single query?

2010-08-31 Thread Russell Warren
Another question on this... Is there any particular reason that orm.query objects don't have as_scalar methods? While trying to hack around and figure out how to make this work, one thing I definitely tried was substituting one-item-result queries in as scalar replacement values in a similar