[sqlalchemy] Re: Declarative Models: Can they be used with two databases and two schema names?

2012-06-07 Thread Shawn Wheatley
Fantastic, that event hack was just what I needed. I did have to change sub to replace on the statement, for any future readers, but that was a trivial change. Thanks Michael! Shawn On Wednesday, June 6, 2012 3:51:55 PM UTC-4, Shawn Wheatley wrote: Hi, I'm trying to use my declarative

Re: [sqlalchemy] Re: Declarative: Joined Inheritance + Two Tables To One Object

2011-05-24 Thread Michael Bayer
On May 23, 2011, at 10:32 PM, Israel Ben Guilherme Fonseca wrote: D'oh, I figured myself, It was very easy. I just followed the guide again and it worked. One question though. Let's use the guide example for this: Let's say that AddressUser inherits(joined inheritance) from another

[sqlalchemy] Re: Declarative: Joined Inheritance + Two Tables To One Object

2011-05-23 Thread Israel Ben Guilherme Fonseca
D'oh, I figured myself, It was very easy. I just followed the guide again and it worked. One question though. Let's use the guide example for this: Let's say that AddressUser inherits(joined inheritance) from another class, and that class have a id with the same name (user_id), I get a warning

[sqlalchemy] Re: declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Yap Sok Ann
On Sep 22, 11:37 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 22, 2010, at 4:30 AM, Yap Sok Ann wrote: This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9... Prior to version 0.6, I use the

[sqlalchemy] Re: declarative base - can a relationship be used within a column_property?

2010-08-21 Thread Yap Sok Ann
On Aug 22, 2:12 am, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 21, 2010, at 1:38 PM, Michael Bayer wrote: On Aug 19, 2010, at 6:38 AM, Yap Sok Ann wrote: With declarative base, is it possible to use a relationship within a column_property? you mean, as I am seeing below, to

[sqlalchemy] Re: declarative autoloading table class with composite foreign/primary key

2010-08-04 Thread jgs9000
Michael thanks very much for your helpful advice - the problem seems to actually involve the autoloading of the table in question. The table structure is as follows: CREATE TABLE wcs ( image_id INTEGER NOT NULL, amp INTEGER

Re: [sqlalchemy] Re: declarative autoloading table class with composite foreign/primary key

2010-08-04 Thread Michael Bayer
On Aug 4, 2010, at 9:05 PM, jgs9000 wrote: Michael thanks very much for your helpful advice - the problem seems to actually involve the autoloading of the table in question. so there's a small bug that is easy to fix, that is ticket #1865 and it is fixed in r742bd985b4e0, latest tip, so

[sqlalchemy] Re: Declarative with mix-in and __table__ fails [patch]

2010-06-04 Thread Gunnlaugur Briem
On Jun 4, 9:23 pm, Michael Bayer mike...@zzzcomputing.com wrote: as long as all tests pass it is fine.  If you could give me a patch that includes a test for this in test_declarative, that would be supremely helpful (if you want to make a trac ticket and target it at the 0.6.2 milestone).

[sqlalchemy] Re: declarative + order_by of 2 columns: is it possible?

2010-05-18 Thread sandro dentella
Hi, On 11 Mag, 18:23, sandro dentella san...@e-den.it wrote: Hi, i have a working declarative configuration that has a relation as this:: client = relation(Cliente, backref='jobs' , lazy=False, order_by=status.desc) now I'd like to add a second column in the order_by field but adding

[sqlalchemy] Re: declarative and session

2009-12-28 Thread karikris...@gmail.com
Thank you so much. I will try adding base class derived from declarative base and implement save, update and delete methods. Regards, Krish On Dec 27, 2:19 pm, Serge Koval serge.ko...@gmail.com wrote: You can always do self.session.add(self) in save() without checks. If your model was already

[sqlalchemy] Re: Declarative, single table inheritance and column type override

2009-12-21 Thread Sergey Koval
Sorry for misleading question. I found the problem and it was related to the index management. Here's sample: ... class Person(DeclarativeBase): id = Column(Integer, primary_key=True) test = Column(Integer, index=True, unique=True) ... and another file: from test import Person class

[sqlalchemy] Re: Declarative base - Joined Table Inheritence

2009-09-27 Thread Jarrod Chesney
I might be getting a bit ambitious here, But is this possible? I'm using a different polymorphic_on for the second level of inheritance. I tried it but it only seems to polymorphicly return records of type _UtConfReconcilerActions class _UtConfActions(Base): __tablename__ =

[sqlalchemy] Re: Declarative base - Joined Table Inheritence

2009-09-16 Thread Conor
On Sep 15, 11:03 pm, Jarrod Chesney jarrod.ches...@gmail.com wrote: Hi All I've been reading the documentation for ages and i can't figure out why when i print the results a query from my inherited table, It just prints them as the base type. I was hoping someone here would be nice enough

[sqlalchemy] Re: Declarative base - Joined Table Inheritence

2009-09-16 Thread Jarrod Chesney
That worked, Thanks, ITS AWESOME :-) On Sep 17, 6:03 am, Conor conor.edward.da...@gmail.com wrote: On Sep 15, 11:03 pm, Jarrod Chesney jarrod.ches...@gmail.com wrote: Hi All I've been reading the documentation for ages and i can't figure out why when i print the results a query from my

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Michael Bayer
Gregg Lind wrote: What I think I'm seeing is that an object can be created even without it's ForeignKeyConstraint being filled. To run the test code below: $ dropdb test18; createdb test18; python testcode.py on is not defined: ForeignKeyConstraint(['regstring_id',

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Conor
On Sep 15, 4:08 pm, Michael Bayer mike...@zzzcomputing.com wrote: Gregg Lind wrote: What I think I'm seeing is that an object can be created even without it's ForeignKeyConstraint being filled. To run the test code below: $ dropdb test18; createdb test18; python testcode.py on is not

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Gregg Lind
Thank you both for the advice. Dern NULLs causing trouble again. GL On Tue, Sep 15, 2009 at 4:34 PM, Conor conor.edward.da...@gmail.com wrote: On Sep 15, 4:08 pm, Michael Bayer mike...@zzzcomputing.com wrote: Gregg Lind wrote: What I think I'm seeing is that an object can be created

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread asrenzo
Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id == neighbors_table.place_id), secondaryjoin= (neighbors_table.neighbor_id == Place.id), secondary=neighbors_table) and the error is: sqlalchemy.exc.InvalidRequestError: When

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Michael Bayer
asrenzo wrote: Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id == neighbors_table.place_id), secondaryjoin= (neighbors_table.neighbor_id == Place.id), secondary=neighbors_table) and the error is:

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Laurent Rahuel
Thanks Michael, Everything is OK now. Sorry for the typo, I was renaming my classes. Regards, Laurent Le 04/09/2009 16:30, Michael Bayer a écrit : asrenzo wrote: Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id ==

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Michael Bayer
Laurent Rahuel wrote: Thanks Michael, Everything is OK now. Sorry for the typo, I was renaming my classes. it wouldn't be tough for us to enhance declarative such that you can name Table objects in those strings as wellsince we have the MetaData available.I'll add a ticket.

[sqlalchemy] Re: declarative style many to many, possible fix

2009-09-02 Thread Michael Bayer
secondary requires a Table object as its argument. it is not recommended to create a relation that uses a mapped table as its secondary unless the relation specifies viewonly=True. Jae Kwon wrote: Is there a way to declaratively create many to many relationships where the 'secondary'

[sqlalchemy] Re: declarative style many to many, possible fix

2009-09-02 Thread Jae Kwon
Thanks for looking. What happens when viewonly=False? I tried appending/popping from the list of related secondary objects but I didn't see any duplicate inserts/deletes. - Jae On Sep 2, 2009, at 8:16 AM, Michael Bayer wrote: secondary requires a Table object as its argument. it is

[sqlalchemy] Re: declarative style many to many, possible fix

2009-09-02 Thread Michael Bayer
Jae Kwon wrote: Thanks for looking. What happens when viewonly=False? I tried appending/popping from the list of related secondary objects but I didn't see any duplicate inserts/deletes. if you create new entities on the secondary table, and also insert records in the relation() with the

[sqlalchemy] Re: declarative style many to many, possible fix

2009-09-02 Thread Jae Kwon
if you create new entities on the secondary table, and also insert records in the relation() with the secondary, it will persist them separately. I see that now. I have found myself using this pattern, however, since relation + secondary can create more efficient joins than an eagerload

[sqlalchemy] Re: Declarative way of delete-orphan

2009-08-26 Thread Mike Conley
Add cascade='delete-orphan' to the relation definition for children. cascade='all,delete-orphan' is also a fairly common option. See the documentation for other options in cascade. http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html#sqlalchemy.orm.relation -- Mike Conley On Wed,

[sqlalchemy] Re: Declarative Base: remote_side single_parent

2009-08-06 Thread Michael Bayer
allen.fowler wrote: I tried: children = relation(Node, backref=backref(parent, remote_side=nodes.id)) got it to work with: remote_side=[id] But: 1) Why is remote_side a list? in this case you could just say remote_side=id. its optionally a list if multiple columns occur on the

[sqlalchemy] Re: Declarative Base: remote_side single_parent

2009-08-06 Thread allen.fowler
On Aug 6, 4:05 pm, Michael Bayer mike...@zzzcomputing.com wrote: allen.fowler wrote: I tried: children = relation(Node, backref=backref(parent, remote_side=nodes.id)) got it to work with: remote_side=[id] But: 1) Why is remote_side a list? in this case you could just say

[sqlalchemy] Re: Declarative base and Adjacency List Relationships

2009-08-04 Thread Werner F. Bruhin
Hi, maxi wrote: Hi, I´ve just using sqlalchemy 0.5.1 with python 2.6 and turbogers, but I found a little problem trying to configurate adjacency relationship with declarative base. My object class is something like this: class QueryGroup(DeclarativeBase): __tablename__ =

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-24 Thread Gregg Lind
Mike, I totally appreciate the help, but it's just not working, for me. I feel like you've given tons of time on trying to fix this, so if anyone else wants to step in to hit me with the clue stick, that would be delightful. More details db's tried: postgres, sqlite sqlalchemy version:

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-24 Thread Michael Bayer
Gregg Lind wrote: session.query(Route.ts,Route.startpoint,Route.target,func.max(Route.hop_id).label('max_hop'))\ .group_by(Route.ts,Route.startpoint,Route.target).subquery() q = session.query(Route,sq.c.max_hop).join(sq,sq.c.max_hop==Route.hop_id) q.all() join takes tuples

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-24 Thread Gregg Lind
Thank you! That tuple thing was a fail on my part, clearly. Doing it exactly as you describe still doesn't get things to be, for lack of a better term, correlated. This, however, achieves what I want: session.query(Route,sq.c.max_hop).join((sq, and_(Route.hop_id==sq.c.max_hop,

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
Gregg Lind wrote: I have read over http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-subqueries and http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg11439.html, but I'm having trouble putting the pieces together. In the demo() below, I want to find the row in the database

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Gregg Lind
On Thu, Jul 23, 2009 at 3:24 PM, Michael Bayermike...@zzzcomputing.com wrote: im assuming you're using MySQL since the GROUP BY below doesn't accommodate every column in the subquery (would be rejected by most DBs). Corrected. It was Sqlite, but good catch. youll want to query each column

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
On Jul 23, 2009, at 5:20 PM, Gregg Lind wrote: How do I implement this join? If I do this: sq = session .query (Route .ts ,Route .startpoint,Route.target,func.max(Route.hop_id).label('max_hop')) sq = sq.group_by(Route.ts,Route.startpoint,Route.target).subquery() then: q =

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
On Jul 23, 2009, at 8:43 PM, Gregg Lind wrote: Hm. I appreciate the help, but something is clearly still failing here. session.query(Route,*sq.c).join(sq.c.max_hop) ArgumentError: Can't find any foreign key relationships between 'route' and 'max_hop' Maybe the filter based solution

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Gregg Lind
Hm. I appreciate the help, but something is clearly still failing here. session.query(Route,*sq.c).join(sq.c.max_hop) ArgumentError: Can't find any foreign key relationships between 'route' and 'max_hop' Maybe the filter based solution is just fine here :) On Thu, Jul 23, 2009 at 7:29 PM,

[sqlalchemy] Re: declarative defer error

2009-06-02 Thread Michael Bayer
quirogaco wrote: File C:\Acappella_2Zero\thirdparty\sqlalchemy\orm\mapper.py, line 1612, in _ instance identitykey = identity_key(row) File C:\Acappella_2Zero\thirdparty\sqlalchemy\orm\mapper.py, line 1553, in i dentity_key return (identity_class, tuple(row[column] for column

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: I use declarative base for defining classes. I have a constraint that only works in Postgres. How do I declare that constraint lowername_check only if the session is going postgres (and not to sqlite, for example). pg_only_constraint = CheckConstraint(lowername !~

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Gregg Lind
As always, thank you for the complete, exhaustive answer. This particular thing is definitely and edge case, and rather non-obvious, so thank you for walking me through it. Either of those are clean enough for me! Is there are more proper / general way to describe the problem, so google and

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: I used the DDL style DDL('''ALTER TABLE data ADD CONSTRAINT lowername_check CHECK (lowername !~ '[[\:upper\:]]')''', on=postgres).execute_at('after-create',Data.__table__) and now my print_schema method (based on

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Gregg Lind
Alas, that doesn't seem to matter or help. Even this statement causes the same issue. Odd. Must not be related to the colons, alas. DDL(r''' ''', on=postgres).execute_at('after-create',Data.__table__) On Fri, May 29, 2009 at 3:08 PM, Michael Bayer mike...@zzzcomputing.com wrote: Gregg

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: Alas, that doesn't seem to matter or help. Even this statement causes the same issue. Odd. Must not be related to the colons, alas. DDL(r''' ''', on=postgres).execute_at('after-create',Data.__table__) didnt realize you're printing with mock. its: buf.write(str(s) +

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
mock is on the way out as a general use tool. Gregg Lind wrote: You got me there! Updating the FAQ on it would fix the issue for others. For reference: ## from sqlalchemy import * from sqlalchemy.schema import DDL from sqlalchemy.ext.declarative import

[sqlalchemy] Re: declarative and __table_args__ I must be missing something simple.

2009-04-08 Thread Wayne Witzel
Yep, there it is. Stupidly simple. Dug up some old know working source that did and diff and grep later I found the cause. __table_args__ needs to be give a tuple with an empty dictionary, like so. __table_args__ = (ForeignKeyConstraint(['parent_id', 'parent_ref'], ['parent.id', 'parent.ref']),

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-25 Thread Christiaan Putter
Hi, Right now I'm really only using multiple threads for speeding up downloads over the internet (which I need to update the data). Actually commiting the data is still done via the gui's thread session. At some point speeding up the algorithms would be nice, a concurrent solution would be

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-25 Thread az
ah. when u don't have an explicit spec, the testcases are the real spec. so make sure u really cover all them funny cases (-: i had the default_values problem too, and to solve it i have split the attr.access into two layers: one that sits below SA (as a fake dict), and one thin that sits on

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-23 Thread az
let me think about it. as i see it u want to have runtime-invented data-only extensions to some object - or is it data + some algo about it? would the algos be new and reside in the new thing or they're just there and used? imo this should be done via joins ala pyprotocols; inheritance is more

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-23 Thread Christiaan Putter
Hi, You're quite right, the join was the tricky bit at first. Basically I construct an outer join over all the 'dynamic' extension classes. Here's an extract: def _get_selectable(self): j = None for key, val in HasTraitsORM._decl_class_registry.iteritems(): if

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-23 Thread az
On Monday 23 March 2009 23:51:26 Christiaan Putter wrote: Hi, You're quite right, the join was the tricky bit at first. ... The 'dynamically' added classes look something like this: class SMAFields(SecurityFields): sma10 = Float(sqldb=True) def _get_sma10(self):

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread az
good on yer! one thing that i sorta failed is making a clean set of tests for this. if u aren't too far in the usage, save some major future headaches and do yourself a favour, make such test set. All the things u've tried has to be (simple) testcases - it will be the _spec_ of how the thing

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread Christiaan Putter
Hi Svilen, Setting up tests is a very good idea, I'll start on some unit testing immediately. Definitely the best way to insure behaviour remains constant as you're working on the implementation, was just to lazy to do so up till now. Speaking of laziness, I've noticed that setting lazy=False

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread az
On Sunday 22 March 2009 21:17:15 Christiaan Putter wrote: Hi Svilen, Setting up tests is a very good idea, I'll start on some unit testing immediately. Definitely the best way to insure behaviour remains constant as you're working on the implementation, was just to lazy to do so up till

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread Christiaan Putter
Oh yeah, before I forget... Regarding the object expiration: The behaviour as it is now in SA is fine I guess, seeing as the purpose of having an ORM is having instances reflect their status in the database at all times. No session means no database and so the behaviour is going to be strange.

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread Christiaan Putter
Hi, Maybe some better explanation is required from my side for you to be able to help me better. My app is basically for doing some plotting, analysis and filtering of securities on the stock market. The main class that does most of the work is Security(HasTraitsORM), where HasTraitsORM is my

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-21 Thread Christiaan Putter
Hi svilen, Thanks for your advice, going through your code helped a lot in understanding how SA works. I've gotten traited classes to behave like classes generated by SA's declarative extension. After a lot of stepping through code I realised the main problem was that SA removes values from an

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-08 Thread az
afaiknow these traits are like my own static_types, i.e. descriptors holding metadata and applying it to attribute access. i have been combining SA with static_type for more than 2 years now, since SA 3.0. The approach i did in the beginning was to replace the object's __dict__ by something

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Christiaan Putter
Hi Michael, Thanks for your swift reply. I wasn't really sure which way to go with combining Traits and SA. From reading through the source it seemed that I had to use InstrumentationManager, I think it said somewhere it was the stable public interface. I had a look at the Trellis source as

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Michael Bayer
On Feb 7, 2009, at 8:27 PM, Christiaan Putter wrote: Hi Michael, Thanks for your swift reply. I wasn't really sure which way to go with combining Traits and SA. From reading through the source it seemed that I had to use InstrumentationManager, I think it said somewhere it was the

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Christiaan Putter
Hi, uh thats a little weird since the InstrumentationManager is designed to be the thing you subclass. you're not supposed to subclass ClassManager. There should be no difference in behavior subclassing one or the other. It behaves a little weird to when I tried it myself. I'll stick

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Michael Bayer
On Feb 7, 2009, at 8:57 PM, Christiaan Putter wrote: yeah thats all true but the point of InstrumentationManager is that its all OK - you send SQLA the events it needs. The question is what events does it need? there's a demo here:

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Christiaan Putter
Thanks for the link. That's where I figured out most of what I'm trying to do. Now that I've stepped through the code I noticed that 'install_state' is only being called on the first 2 iterations of the loop. Haven't found out yet why that is. What exactly is supposed to be in the state? Is

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-07 Thread Michael Bayer
install_state is normally called during __init__ of your object. the attributes package decorates __init__ for this purpose. so you have to get __init__, or __new__, or whatever, to ensure that attributes.instance_state(obj) will return an InstanceState at all times. On Feb 7, 2009,

[sqlalchemy] Re: Declarative Base ID

2009-02-01 Thread Michael Bayer
primary key identifiers are acquired using database-specific methods, such as AUTOINCREMENT on mysql, SERIAL on postgres, SQLites implicit OID behavior. these methods all start at 1. you can explicitly set the primary key attributes on a pending object to 0 and flush to force a zero.

[sqlalchemy] Re: Declarative Base ID

2009-02-01 Thread vctr...@gmail.com
Thanks On Feb 1, 7:17 pm, Michael Bayer mike...@zzzcomputing.com wrote: primary key identifiers are acquired using database-specific methods,   such as AUTOINCREMENT on mysql, SERIAL on postgres, SQLites implicit   OID behavior.   these methods all start at 1.   you can explicitly set   the

[sqlalchemy] Re: Declarative and relation to self

2009-01-06 Thread Gennady Kovalev
On 6 янв, 23:05, Michael Bayer zzz...@gmail.com wrote: this was a bug in 0.5.0rc4 and is fixed in 0.5.0. On Jan 6, 2:49 pm, Gennady Kovalev gennady.kova...@gmail.com wrote: Hi! I try to clean up my code, and read in google group about possibility create relation to self when class is

[sqlalchemy] Re: Declarative and relation to self

2009-01-06 Thread Gennady Kovalev
On 6 янв, 23:05, Michael Bayer zzz...@gmail.com wrote: this was a bug in 0.5.0rc4 and is fixed in 0.5.0. Ohh, thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group,

[sqlalchemy] Re: declarative inheritance

2008-11-11 Thread Michael Bayer
sure its along these lines class Content(my_declarative_base): __tablename__ = 'content' id = Column(Integer, primary_key=True) title = Column(String(80)) parent_id = Column(Integer, ForeignKey('content.id')) type = Column(String(32)) children =

[sqlalchemy] Re: declarative and self-referential table

2008-11-11 Thread Michael Bayer
always use remote_side=table.c.id on the many to one side of a self referential relation, in the case of declarative it would look like remote_side=id. See http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_selfreferential for information on this. On Nov 11, 2008,

[sqlalchemy] Re: declarative and self-referential table

2008-11-11 Thread MikeCo
Thanks for the pointer about remote_side. In my application, the table definitions are not visible at runtime, and the class definitions are autoloaded from the engine. So, I can't say remote_side=table.c.id because table is not available. I do have this solution that works well: class

[sqlalchemy] Re: declarative and self-referential table

2008-11-11 Thread Michael Bayer
On Nov 11, 2008, at 4:52 PM, MikeCo wrote: Thanks for the pointer about remote_side. In my application, the table definitions are not visible at runtime, and the class definitions are autoloaded from the engine. So, I can't say remote_side=table.c.id because table is not available. I do

[sqlalchemy] Re: declarative, autoload and late binding to engine

2008-11-06 Thread Martijn Faassen
Hi there, MikeCo wrote: I have an application that will need to bind to several different databases with the same structure. The databases to be accessed are not known at import time, that will be determined later while the application is running. I want to use declarative and autoload the

[sqlalchemy] Re: Declarative application example

2008-10-28 Thread Michael Bayer
On Oct 28, 2008, at 9:32 AM, writeson wrote: Hi everyone, I'm struggling to try and use SqlAlchemy (0.5rc2) with a project I'm working on. The database part isn't very hard, it's just a flat table, but I keep running into problems with SA throwing exceptions. The SA documentation is

[sqlalchemy] Re: Declarative application example

2008-10-28 Thread Doug Farrell
28, 2008 10:30 AM To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: Declarative application example On Oct 28, 2008, at 9:32 AM, writeson wrote: Hi everyone, I'm struggling to try and use SqlAlchemy (0.5rc2) with a project I'm working on. The database part isn't very

[sqlalchemy] Re: Declarative and common fields

2008-09-29 Thread az
i dont know if elixir has such 'attribute/behaviour injectors', i have DBCOOK_no_mapping=True in dbcook.sf.net that does that. the machinery behdin it is soewhat tricky (x in class.__dict__ and not in base_class.__dict__ etc stuff) u may try your stuff as mixin, that may or may not work. On

[sqlalchemy] Re: Declarative and common fields

2008-09-29 Thread Gaetan de Menten
On Mon, Sep 29, 2008 at 5:01 PM, Joril [EMAIL PROTECTED] wrote: Hi everyone! I'm new to SQLAlchemy and I'm using version 0.5rc1.. I need every entity class to have a few common fields, so I tried writing an abstract base class, declarative-style, that every other entity class would

[sqlalchemy] Re: Declarative and common fields

2008-09-29 Thread Joril
I don't know whether this is currently possible with Declarative or not. In the case it isn't, patching Declarative should be quite easy (but I don't know if such a patch would be accepted or not). I see.. I'll wait a bit then, maybe one of the developers will tell us if it'd be acceptable :)

[sqlalchemy] Re: Declarative and common fields

2008-09-29 Thread Michael Bayer
On Sep 29, 2008, at 11:01 AM, Joril wrote: Hi everyone! I'm new to SQLAlchemy and I'm using version 0.5rc1.. I need every entity class to have a few common fields, so I tried writing an abstract base class, declarative-style, that every other entity class would subclass. So for example:

[sqlalchemy] Re: Declarative documentation

2008-09-17 Thread Empty
Hi Doug, I'm a new user (like this week) of SqlAlchemy and I'm trying to find more information about using the Declarative system. In particular I'm trying to build a hierarchical table with one-to-many relationships within the table. So if anyone knows where there might be some additional

[sqlalchemy] Re: Declarative documentation

2008-09-17 Thread Doug Farrell
: [sqlalchemy] Re: Declarative documentation Hi Doug, I'm a new user (like this week) of SqlAlchemy and I'm trying to find more information about using the Declarative system. In particular I'm trying to build a hierarchical table with one-to-many relationships within the table. So

[sqlalchemy] Re: declarative

2008-08-21 Thread Jim Jones
On Tue, 2008-08-19 at 16:16 -0400, Michael Bayer wrote: On Aug 19, 2008, at 4:07 PM, Gaetan de Menten wrote: Simpler than Elixir? How so? If you are speaking about the internal guts, then you are right declarative is simpler (which is normal since it does less), but if you meant the

[sqlalchemy] Re: declarative

2008-08-21 Thread Gaetan de Menten
On Thu, Aug 21, 2008 at 2:06 PM, Jim Jones [EMAIL PROTECTED] wrote: On Tue, 2008-08-19 at 16:16 -0400, Michael Bayer wrote: On Aug 19, 2008, at 4:07 PM, Gaetan de Menten wrote: Simpler than Elixir? How so? If you are speaking about the internal guts, then you are right declarative is

[sqlalchemy] Re: declarative

2008-08-21 Thread Jim Jones
On Thu, 2008-08-21 at 16:08 +0200, Gaetan de Menten wrote: Everyone else will eventually grow out of it. That's quite a bold claim... Ok, Elixir is not your style, that's fine. Also, Elixir certainly doesn't suit every project out there, I'm aware of that. But implying it's not worth it

[sqlalchemy] Re: declarative

2008-08-21 Thread az
well, if u want something that looks simpler but is actualy quite more complex/twisted inside, try dbcook.sf.net. it tries to hide _all the sql-schema stuff for u. but it's definitely not for faint-hearted, no time to brush it up... even the examples look like a battle field.

[sqlalchemy] Re: declarative

2008-08-19 Thread Jose Galvez
I take it back about Elixir and legacy databases, it seems to work with them just as easy as sqlalchemy does. I'll have to look much closer at Elixir Jose Jose Galvez wrote: What is the proposed stability of declarative functions which I guess are pretty new. From what I've read so far I

[sqlalchemy] Re: declarative

2008-08-19 Thread Michael Bayer
On Aug 19, 2008, at 2:43 PM, Jose Galvez wrote: What is the proposed stability of declarative functions which I guess are pretty new. From what I've read so far I really like it and was thinking of using it, but was just wondering what the long turn outlook for it looked like? After

[sqlalchemy] Re: Declarative 0.5 tutorial fails to create tables before insert

2008-07-18 Thread Kris Kennaway
Thanks, this wasn't clear from the tutorial. Kris On Jul 18, 6:04 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 17, 2008, at 4:44 PM, Kris Kennaway wrote: from sqlalchemy.orm import sessionmaker Session = sessionmaker(bind=engine) session = Session() ed_user = User('ed',

[sqlalchemy] Re: Declarative 0.5 tutorial fails to create tables before insert

2008-07-17 Thread Michael Bayer
On Jul 17, 2008, at 4:44 PM, Kris Kennaway wrote: from sqlalchemy.orm import sessionmaker Session = sessionmaker(bind=engine) session = Session() ed_user = User('ed', 'Ed Jones', 'edspassword') session.add(ed_user) session.add_all([ User('wendy', 'Wendy Williams', 'foobar'),