[sqlalchemy] foreign_keys changing cascade behavior for relationships? users going away.

2011-08-25 Thread Daniel Robbins
Hi there. I have an application that has three different databases in MySQL (InnoDB). They are separated into distinct databases because sometimes I need to reload a database from scratch without impacting the other databases. For this reason, there are no ForeignKey() relationships defined at

Re: [sqlalchemy] Repetitive Fields in declarative

2011-08-19 Thread Daniel Robbins
On Fri, Aug 19, 2011 at 9:23 AM, Mark Erbaugh m...@microenh.com wrote: On Aug 19, 2011, at 10:41 AM, Michael Bayer wrote: Id use a mixin so that a superclass can be generated in a data driven manner: MyCols = type(MyCols, (object, ), dict((field%d % i, Column(Integer)) for i in

[sqlalchemy] mysql table creation errno 105 when using vertical partitioning with InnoDB

2011-08-11 Thread Daniel Robbins
Hi there, I have been using ORM vertical partitioning for a while with MySQL 5.1.58 and MyISAM tables and SQLAlchemy 0.7.2. I have recently switched over to using InnoDB tables and my vertical partitioning table creation is failing part-way in with an errno 105 code. I have confirmed that all

Re: [sqlalchemy] mysql table creation errno 105 when using vertical partitioning with InnoDB

2011-08-11 Thread Daniel Robbins
On Thu, Aug 11, 2011 at 12:20 PM, Michael Bayer mike...@zzzcomputing.comwrote: Vertical partitioning implies tables in separate databases or schemas. It seems like you have it set up such that a table in partition A can refer to a table in partition B using a schema qualifier. So if this is

Re: [sqlalchemy] mysql table creation errno 105 when using vertical partitioning with InnoDB

2011-08-11 Thread Daniel Robbins
On Thu, Aug 11, 2011 at 2:12 PM, Michael Bayer mike...@zzzcomputing.comwrote: Just FYI the Oreilly book is super, duper, extremely old and out of date. A good read through the documentation on the SQLAlchemy site should be more complete at this point and up to date, also stressing a whole

[sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
Hi All, Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed.) What mechanisms are suggested for this? I could add a save() method to my declarative class that

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
On Wed, Apr 28, 2010 at 10:04 AM, Chris Withers ch...@simplistix.co.uk wrote: Daniel Robbins wrote: Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
On Wed, Apr 28, 2010 at 10:25 AM, King Simon-NFHD78 simon.k...@motorola.com wrote: The declarative docs include an example of using a MapperExtension: http://www.sqlalchemy.org/docs/reference/ext/declarative.html#mapper-con figuration Great, thanks for everyone's help. This is exactly the

Re: [sqlalchemy] Re: SQLAlchemy Sessions

2010-03-29 Thread Daniel Robbins
On Sun, Mar 28, 2010 at 10:19 AM, Peteris Krumins peteris.krum...@gmail.com wrote: This is the best explanation I have read on this topic! Thanks for writing it! Now I clearly see what is going on. Just one more thing - when should remove() be called? (if at all) The model that works for me

[sqlalchemy] need 0.6_beta2-compat declarative meta

2010-03-27 Thread Daniel Robbins
Hi All, In 0.6_beta2, the following code is not properly adding a primary key Column via DeclarativeMeta which calls my PrimaryKey() function: def PrimaryKey(seqprefix): return Column(Integer, Sequence(seqprefix, optional=True), primary_key=True) class ClassDefaults(DeclarativeMeta):

Re: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-27 Thread Daniel Robbins
On Mar 23, 2010, at 9:29 AM, King Simon-NFHD78 wrote: object_session does indeed return the session that the instance is already bound to (so you shouldn't close it). I didn't know what object_session would return if the original session had been closed, so I tried it: Thanks for looking into

Re: [sqlalchemy] Re: need 0.6_beta2-compat declarative meta

2010-03-27 Thread Daniel Robbins
On Mar 27, 2010, at 5:58 AM, Chris Withers wrote: avdd wrote: In a metaclass's __init__, the attributes have already been placed on the class, so mutating the attributes dict has no effect. Spot on. SA fudged this prior to 0.6beta so you could get away with shoving stuff in dict_, you now

Re: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-22 Thread Daniel Robbins
On Mar 22, 2010, at 5:10 AM, King Simon-NFHD78 wrote: See the 'How can I get the Session for a certain object' question at http://www.sqlalchemy.org/docs/session.html#frequently-asked-questions Basically, in your FindFriends method, replace: session = Session() with: session =

[sqlalchemy] recommended declarative method design pattern for sessions

2010-03-21 Thread Daniel Robbins
Hi All, One of the things that doesn't seem to be covered in the docs, and that I'm currently trying to figure out, is the recommended design pattern to use for managing sessions from declarative methods calls. Consider a declarative class User, where I want to implement a FindFriends()

Re: [sqlalchemy] composite index using declarative

2010-03-16 Thread Daniel Robbins
On Tue, Mar 16, 2010 at 8:08 AM, Michael Bayer mike...@zzzcomputing.com wrote: we definitely should because I am amazed at how often this question gets asked.   But the more puzzling thing is that it means the central tenet of declarative isn't getting across to people, which is that nothing

Re: [sqlalchemy] composite index using declarative

2010-03-16 Thread Daniel Robbins
On Tue, Mar 16, 2010 at 10:29 AM, Michael Bayer mike...@zzzcomputing.com wrote: Daniel Robbins wrote: People want to *start* with declarative, whereas you as the architect started with the core parts of the framework and recently added declarative. So you know all the underpinnings, but most

[sqlalchemy] composite index using declarative

2010-03-15 Thread Daniel Robbins
Hi All, How does one define a composite index using declarative? Quick example? Couldn't find any examples in the docs or online. In my particular case, id will be a primary key, and I'd like a composite UniqueConstraint on group_id and name, and a composite index on group_id (pos 1) and name

Re: [sqlalchemy] composite index using declarative

2010-03-15 Thread Daniel Robbins
On Mar 15, 2010, at 4:58 PM, Michael Bayer wrote: we have some index examples at http://www.sqlalchemy.org/docs/metadata.html#indexes . the Index is not related to declarative and is specified separately. Any plans to improve this? I would have thought that Indexes would be defined under

Re: [sqlalchemy] case sensitive Unicode and String columns

2010-03-04 Thread Daniel Robbins
On Thu, Mar 4, 2010 at 11:34 AM, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I'm looking to create a model with a unicode or string column type that is case sensitive. I'm looking to do this in the model in such a way that the code in the model doesn't know or care about what

[sqlalchemy] Base class with primary key and sequence (Mix-in?)

2010-03-04 Thread Daniel Robbins
Hi All, I have created a base declarative object that has a pre-made primary key, so I don't have to add it to all my child tables: class ClassDefaults(DeclarativeMeta): def __init__(cls,classname, bases, dict_): dict_['id'] = Column(Integer, Sequence(id_seq,

[sqlalchemy] Primary key Mix-in not working with adjacency list

2010-03-04 Thread Daniel Robbins
Hi all, I tried to convert some existing code containing an adjacency list to mix-ins, and the mix-in version doesn't seem to be liked by SQLAlchemy 0.6_beta1: Original code that works: class ClassDefaults(DeclarativeMeta): def __init__(cls,classname, bases, dict_):

[sqlalchemy] Re: Base class with primary key and sequence (Mix-in?)

2010-03-04 Thread Daniel Robbins
On Thu, Mar 4, 2010 at 2:31 PM, Daniel Robbins drobb...@funtoo.org wrote: Hi All, I have created a base declarative object that has a pre-made primary key, so I don't have to add it to all my child tables: I figured out how to do this, using the following code: seqnum=0 def PrimaryKey