[sqlalchemy] Automatically execute a procedure on saving/loading from Sql database with SQLAlchemy (and MeGrok)

2010-10-25 Thread Hector Blanco
Hello everyone. First of all, thank you for reading this (no matter whether you can/want to help me or not) :-) Second, the question: I am using sqlalchemy under MeGrok (http://pypi.python.org/pypi/megrok.rdb) to have my Python/Grok classes stored over a RDBMS (MySql) database. I have a Python

[sqlalchemy] Re: Automatically execute a procedure on saving/loading from Sql database with SQLAlchemy (and MeGrok)

2010-10-25 Thread Hector Blanco
Wow... I just saw this... http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#sqlalchemy.types.TypeDecorator Maybe that's what I need! I'll confirm (for future questions) :-) 2010/10/25 Hector Blanco white.li...@gmail.com Hello everyone. First of all, thank you for reading this

[sqlalchemy] Recursive problem

2010-10-25 Thread Alvaro Reinoso
Hey guys, I have a problem when I import classes from one to another. I have those classes in different modules: crm.py from CRMContactInformation import CRMContactInformation class CRM(rdb.Model): Set up crm table in the database rdb.metadata(metadata)

[sqlalchemy] Re: Automatically execute a procedure on saving/loading from Sql database with SQLAlchemy (and MeGrok)

2010-10-25 Thread Hector Blanco
Yuuup... It works like a charm! I have created a simple class that gets a dictionary and serializes its values. The underlying database is MySql... Just in case my code may help someone (or if someone has any suggestions...) here it goes: from sqlalchemy import types import logging log =

[sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-25 Thread Lenza McElrath
I am running into a issue where it looks like SQLAlchemy is not performing the proper DB update when committing a session after modifying an object. This happens only when all references to the updated object are lost, and I update a mutable attribute BEFORE updating another attribute. It seems

[sqlalchemy] Re: Automatically execute a procedure on saving/loading from Sql database with SQLAlchemy (and MeGrok)

2010-10-25 Thread Hector Blanco
I hate when the identation gets messed up... Gonna try again: Yuuup... It works like a charm! I have created a simple class that gets a dictionary and serializes its values. The underlying database is MySql... Just in case my code may help someone (or if someone has any suggestions...) here it

Re: [sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-25 Thread Michael Bayer
On Oct 25, 2010, at 1:07 PM, Lenza McElrath wrote: I am running into a issue where it looks like SQLAlchemy is not performing the proper DB update when committing a session after modifying an object. This happens only when all references to the updated object are lost, and I update a

[sqlalchemy] Unique Identifier for newly added child records?

2010-10-25 Thread Mark Erbaugh
Does SA maintain a usable unique identifier for newly added child records before the data is committed? I have a mapping of a one-many relationship using a foreign key. The detail (many side) records are in an instrumented list. I need to relate the items in this list to rows in an user

[sqlalchemy] Re: Recursive problem

2010-10-25 Thread Alvaro Reinoso
I solved the problem delaying the imports like: from zeppelinlib.screen.ScreenTest import Screen CRMContactInformation.id = Column(id, Integer, ForeignKey(Screen.id), primary_key=True) On Oct 25, 11:18 am, Alvaro Reinoso alvrein...@gmail.com wrote: Hey guys, I have a problem when I import

[sqlalchemy] Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
Hello, I get errors when I try to create tables one to one relation. Screen contains crm and crm contains more classes. The relation is one to one between crm, so I want to use the screen id as primary key in crm. And the relation is one to one between crm and some classes, I just added one class

Re: [sqlalchemy] Unique Identifier for newly added child records?

2010-10-25 Thread Michael Bayer
On Oct 25, 2010, at 2:19 PM, Mark Erbaugh wrote: Does SA maintain a usable unique identifier for newly added child records before the data is committed? I have a mapping of a one-many relationship using a foreign key. The detail (many side) records are in an instrumented list. I need to

Re: [sqlalchemy] Problems creating tables one to one relation

2010-10-25 Thread Michael Bayer
all modules which include mapped classes must be imported before you attempt to initialize the mappings. If class A references B, but class B doesn't exist, you get errors like that, so importing the modules that contain both class A and B solves the issue. On Oct 25, 2010, at 2:55 PM, Alvaro

Re: [sqlalchemy] Unique Identifier for newly added child records?

2010-10-25 Thread Mark Erbaugh
On Oct 25, 2010, at 3:57 PM, Michael Bayer wrote: On Oct 25, 2010, at 2:19 PM, Mark Erbaugh wrote: Does SA maintain a usable unique identifier for newly added child records before the data is committed? I have a mapping of a one-many relationship using a foreign key. The detail

[sqlalchemy] Re: Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
I think it should be another problem because I have a file where I initialize all the tables, so that file contains all the tables. The tables are created properly, but when I try to create a Screen object (the main class, Screen - CRM - CRMContactInformation), I get this error:

Re: [sqlalchemy] Re: Problems creating tables one to one relation

2010-10-25 Thread Michael Bayer
On Oct 25, 2010, at 4:59 PM, Alvaro Reinoso wrote: I think it should be another problem because I have a file where I initialize all the tables, so that file contains all the tables. The tables are created properly, but when I try to create a Screen object (the main class, Screen - CRM -

[sqlalchemy] Problem updating mapped child class

2010-10-25 Thread Massi
Ok, the title doesn't say much, so I'll try to explain my problem with an example: I have two classes: class A(object) : pass class B(object) : pass which are bounded by a relation: a_tab = Table(...) b_tab = Table(...) b_tab.append_constraint(ForeignKeyConstraint([a_tab.c.id],

[sqlalchemy] Re: Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
It's fixed. I was my mistake, I didn't realize it. Thank you! On Oct 25, 5:19 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 25, 2010, at 4:59 PM, Alvaro Reinoso wrote: I think it should be another problem because I have a file where I initialize all the tables, so that file

[sqlalchemy] InvalidRequestError: Unknown PG numeric type: 23

2010-10-25 Thread ellonweb
I've added a few extra columns to one of my tables (nothing fancy, just plain Integers and Floats) and created them manually in the db. Now every time I try to query an object from this table I get the error in the subject. Using declarative in SA 0.6.3 on PG8.4. Traceback below, any help is much

Re: [sqlalchemy] InvalidRequestError: Unknown PG numeric type: 23

2010-10-25 Thread Michael Bayer
this sounds like you're receiving an INTEGER column as a Numeric or Float. We should get 23 and such in there, thought we had gotten to this already but apparently not so ticket #1955 is added but for now make sure that column is declared as Integer. On Oct 25, 2010, at 7:35 PM, ellonweb