Re: [sqlalchemy] case_convention in db python code

2011-01-06 Thread Petr Kobalíček
_ + matchobj.group(0).lower()    if text:        text = text[0].lower() + re.sub(r'([A-Z])', downcase, text[1:])    return text On Jan 5, 2011, at 2:41 PM, Petr Kobalíček wrote: Hi, I'm using underscored_separator_convention in a database, but camelCase in python code. I created small wrapper

[sqlalchemy] case_convention in db python code

2011-01-05 Thread Petr Kobalíček
Hi, I'm using underscored_separator_convention in a database, but camelCase in python code. I created small wrapper across a table column so I don't need to define columns using a key property: from sqlalchemy import Column as SqlColumn def underscored(s): result = u for i in xrange(0,

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:

[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
, Sep 1, 2010 at 2:15 AM, Petr Kobalíček kobalicek.p...@gmail.com 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

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 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

Re: [sqlalchemy] Re: Read only property

2010-08-30 Thread Petr Kobalíček
= { id: RecordTable.c.record_id, idx: RecordTable.c.idx, MARK ReadOnly? msg: RecordTable.c.msg } ) Thanks a lot Best regards Petr Kobalicek On Mon, Aug 30, 2010 at 4:51 AM, Petr Kobalíček kobalicek.p...@gmail.com wrote: Hi devs, thanks for replies! Michael: I asked

[sqlalchemy] DDL and TypeError: 'dict' object does not support indexing

2010-08-30 Thread Petr Kobalíček
Hi devs, I added %% into my DDL and sqlalchemy raises the TypeError: 'dict' object does not support indexing. The critical part is: row_array t_record%%ROWTYPE in the DDL. Em I using the DDL correctly? I read that I need to double the '%' character and I did that. Best regards Petr

Re: [sqlalchemy] DDL and TypeError: 'dict' object does not support indexing

2010-08-30 Thread Petr Kobalíček
Hi Michael, thanks for reply, I tried triple escaping before I posted the first message, but the error is the same. Interesting is fact that i can add 20 '%' characters into the DDL but in SQL INFO I always see only one '%'. Is there other workaround? Can I safely replace the line described in:

Re: [sqlalchemy] DDL and TypeError: 'dict' object does not support indexing

2010-08-30 Thread Petr Kobalíček
Hi Michael, triple escaping works, sorry for misinformation. Best regards Petr -- 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] Read only property

2010-08-29 Thread Petr Kobalíček
Hi devs, is there a simple way how to make an ORM property read only? I need to fetch the column from database so it will be accessible through the mapped class, but I need that the property will be never updated back to the database (in case I add the object to the session and do commit).

[sqlalchemy] Help with select where clause is more than one tag

2010-06-28 Thread Petr Kobalíček
Hi devs, I need to write a query where two tags match one product. I wrote simple test-case I'm using with sqlite: #!/usr/bin/env python from sqlalchemy import * from sqlalchemy.sql import and_, or_ engine = create_engine(sqlite://, echo=True) metadata

[sqlalchemy] Re: Help with select where clause is more than one tag

2010-06-28 Thread Petr Kobalíček
and I have: query = select([ProductTable]) ... How can I extend this query by the query shown above? Thanks - Petr On Mon, Jun 28, 2010 at 9:40 AM, Petr Kobalíček kobalicek.p...@gmail.com wrote: Hi devs, I need to write a query where two tags match one product. I wrote simple test-case

[sqlalchemy] many to many join condition

2009-12-02 Thread Petr Kobalíček
Hi devs, I have one problem related to join and adding conditions (sorry for misleading subject, I don't know how to describe it shortly). I have two tables: Product Tag There is many to many relation between tag and products and I need to select product where two tags are set. How to do

[sqlalchemy] Re: inserting

2008-11-26 Thread Petr Kobalíček
So, I can use that way in inserting one row, but can't when inserting multiple rows ? It is correct ? 2008/11/24 Michael Bayer [EMAIL PROTECTED]: oh, right. Column objects only work when you say insert().values(**dict). MikeCo wrote: Using 0.5.0rc4 doesn't seem to do that. or what am I

[sqlalchemy] inserting

2008-11-23 Thread Petr Kobalíček
Hi devs, I don't understand one thing: I have table: CartItemTable = sql.Table( CartItem, meta.metadata, # Relations sql.Column(userId , sql.Integer , sql.ForeignKey(User.userId), nullable=False, primary_key=True), sql.Column(productId , sql.Integer ,

[sqlalchemy] Re: Postgres - Backup - Restore

2008-11-10 Thread Petr Kobalíček
Hi Chris, yeah these tools works great, our problem was that if I did backup and restoration from web interface then this problem happen. I wasn't also familiar with postgres :) Cheers - Petr 2008/11/10 Chris Miles [EMAIL PROTECTED]: On Nov 10, 4:57 am, Petr Kobalíček [EMAIL PROTECTED

[sqlalchemy] Re: Postgres - Backup - Restore

2008-11-09 Thread Petr Kobalíček
Thank you Michael. 2008/11/9 Michael Bayer [EMAIL PROTECTED]: you need to call ALTER SEQUENCE on your sequences such that they begin with an integer identifier greater than that of the table they are being used with. On Nov 9, 2008, at 1:22 PM, Petr Kobalíček wrote: I have found some

[sqlalchemy] Postgres - Backup - Restore

2008-11-09 Thread Petr Kobalíček
Hi devs, I have postgres related problem. I'm normally developing with sqlite, but we are using postgres on the server. The problem is that sqlalchemy probably remembers primary keys and after database restore it will start in all tables from 1. The error is (IntegrityError) duplicate key

[sqlalchemy] Re: Postgres - Backup - Restore

2008-11-09 Thread Petr Kobalíček
I have found some material about this and this is called 'sequences' in postgres terminology. So I know the problem, but I don't know how to synchronize sequences using sqlalchemy. Cheers - Petr 2008/11/9 Petr Kobalíček [EMAIL PROTECTED]: Hi devs, I have postgres related problem. I'm