[sqlalchemy] how to delete record (special case)

2011-04-06 Thread farcat
Hello, I am experimenting with a pattern where records hold the table name and record id of the next record in any other table, chaining records in different tables. This works, but I can't figure out how to clean op references to the next record in another table when I delete a record (the

[sqlalchemy] Re: when is object.id initialized

2011-04-06 Thread farcat
/docs/orm/tutorial.html#adding-new-objectsyou will see that this interaction is described. You can of course set .id to any value you'd like and that will be the value used when the flush happens. On Apr 3, 2011, at 1:09 PM, farcat wrote: Hi all, I use a kind of dynamic reference

[sqlalchemy] Re: difficult error from Base.metadata.create_all(engine)

2011-04-03 Thread farcat
in dynamic other tables.) Hope this helps someone in the future; the error messages can be very confusing. On Apr 2, 2:59 pm, farcat gemer...@gmail.com wrote: Hello, I get the following error: ___ Traceback (most recent call last):   File D:\Documents\Code\Eclipse

[sqlalchemy] when is object.id initialized

2011-04-03 Thread farcat
Hi all, I use a kind of dynamic reference from parent_table to other tables. For that parent_table uses columns table_name and a record_id. This makes it possible to have a reference from parent_table to any record in any table in the database. However, say that i want to reference a record of

[sqlalchemy] Re: difficult error from Base.metadata.create_all(engine)

2011-04-03 Thread farcat
, farcat wrote: The problem seemed to be in the order of adding relationships. The main difference is that now i call DeclarativeMeta.__init__ before adding relationships. Even using a dict with relationship attributes as last argument to __init__ did not work.( BTW cls.links is a table

[sqlalchemy] Re: difficult error from Base.metadata.create_all(engine)

2011-04-02 Thread farcat
He Michael, You saved me again .. Thanks! On Apr 2, 2:09 am, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 1, 2011, at 2:52 PM, farcat wrote: Hi Michael, Still stuck, I don't mixin foreign keys or relationships. When is a Column attached to a table in declarative? so you have

[sqlalchemy] Re: difficult error from Base.metadata.create_all(engine)

2011-04-02 Thread farcat
or related class/table F_Address. Please help ... It might be related to the ForeignKey in the code I showed earlier in this thread, but I don't see how. On Apr 2, 11:56 am, farcat gemer...@gmail.com wrote: He Michael, You saved me again .. Thanks! On Apr 2, 2:09 am, Michael Bayer mike

[sqlalchemy] Re: difficult error from Base.metadata.create_all(engine)

2011-04-01 Thread farcat
help The typedefs variables describe classes and members, and are queried from normal tables On Mar 31, 5:33 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 31, 2011, at 11:29 AM, farcat wrote: Hi, I am getting the following error after creating a number of classes

[sqlalchemy] difficult error from Base.metadata.create_all(engine)

2011-03-31 Thread farcat
Hi, I am getting the following error after creating a number of classes through metaclasses: Traceback (most recent call last): File D:\Documents\Code\Eclipse\workspace\SQLAtest\data.py, line 20, in module createClasses(engine, session) File

[sqlalchemy] stuck on IntegrityError

2011-03-28 Thread farcat
Hi all, I am stuck on an integrity error. The code worked before, but i cannot figure out what changed so it does not anymore. It is possibly a dumn oversight. The code is: from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import

[sqlalchemy] Re: stuck on IntegrityError

2011-03-28 Thread farcat
I don't know whether to laugh or cry ... thanks On Mar 28, 6:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: your enum is set for uni, list, set and you're passing in one On Mar 28, 2011, at 6:35 AM, farcat wrote: Hi all, I am stuck on an integrity error. The code worked

[sqlalchemy] Re: trouble with metaclass

2011-03-21 Thread farcat
:27, farcat wrote: OK, dumb error, move Base.metadata.create_all(engine)  below table1 = tablemeta(table1)  and it works. This works when I create the columns via the temp dict in __new__ not when I do so in __init__ (it complains about missing __tabledata__), but why? I'd strongly

[sqlalchemy] Re: trouble with metaclass

2011-03-18 Thread farcat
, Chris Withers ch...@simplistix.co.uk wrote: On 16/03/2011 21:01, farcat wrote: I have an error i cant figure out (likely a beginners error): Beginners should not be using metaclasses. What's your use case here? Chris -- Simplistix - Content Management, Batch Processing Python

[sqlalchemy] trouble with metaclass

2011-03-16 Thread farcat
I have an error i cant figure out (likely a beginners error): # Base = declarative_base() class tablemeta(DeclarativeMeta): def __new__(mcls, name): return DeclarativeMeta.__new__(mcls, name, (Base,), {}) def _init__(cls,

[sqlalchemy] Re: overriding DeclarativeBase and descriptors

2011-03-07 Thread farcat
thanks, I will start experimenting ... On Mar 5, 4:52 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 5, 2011, at 10:43 AM, farcat wrote: Hi, I am trying to implement polymorphism and multiple inheritance by: - adding a column to the parent class/table indicating

[sqlalchemy] overriding DeclarativeBase and descriptors

2011-03-05 Thread farcat
Hi, I am trying to implement polymorphism and multiple inheritance by: - adding a column to the parent class/table indicating the table from which the (polymorphic) class attribute object can be queried - adding the attribute name and the parent id to the child table/class to be able to find the

[sqlalchemy] multiple inheritance simplified case

2011-03-01 Thread farcat
Hi, I have been reading the posts on implementing multiple inheritance in SA. I have a question, for a slightly simpler method of MI, where there is no overriding of attributes (and e.g. therefore no diamond problem). This would mean that all underlying tables for classes could contain columns

[sqlalchemy] Re: adjacency via table

2011-02-22 Thread farcat
thought i'd post the code I came up with for reference: from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker from sqlalchemy.ext.associationproxy import association_proxy Base = declarative_base() def

[sqlalchemy] Re: adjacency via table

2011-02-20 Thread farcat
Thank you, Basically the multiple inheritance structure is a directional non- cyclic graph (i looked at the graph example code in the distribution, it uses methods to get next/previous nodes) . Members are basically another name for attributes. I understand the need for the primaryjoin now.

[sqlalchemy] Re: adjacency via table

2011-02-20 Thread farcat
Thank you, Basically the multiple inheritance structure is a directional non- cyclic graph (i looked at the graph example code in the distribution, it uses methods to get next/previous nodes, which could serve as a workaround, but seems inelegant) . Members are basically another name for

[sqlalchemy] Re: adjacency via table

2011-02-20 Thread farcat
Thank you, the many to many (following the pattern in the link above) seems to work, now on to the association table (later ... ) Cheers BTW: in A - (one to many) B - C, does (seen from A) primaryjoin refer to the relation between A and B and secondaryjoin to the relation between B and C?

[sqlalchemy] adjacency via table

2011-02-19 Thread farcat
Hi, I am trying to implement tables to store a basic multiple inheritance scheme via SA. I am pretty new to SA and could use some help with the following code: code from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship,

[sqlalchemy] dynamic classes and tables

2011-02-08 Thread farcat
Hi everyone, I am new to sqlalchemy and figuring out whether it is right for my project. What I am looking for is the ability to change classes and tables on the flight, with as much freedom as possible, potentially having metaclasses figuring out the difference between versions and updating the

[sqlalchemy] Re: dynamic classes and tables

2011-02-08 Thread farcat
Thank you, that works. Is there any way to later add or remove attributes, using the declarative system? Cheers, Lars On Feb 8, 10:46 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 8, 2011, at 3:52 PM, farcat wrote: Hi everyone, I am new to sqlalchemy and figuring out