[sqlalchemy] mapping adjacency lists

2009-02-01 Thread n00b
g'day, i wanted to give the adjacency pattern a try in the context of a dog pedigree database and used http://groups.google.com/group/sqlalchemy/browse_thread/thread/d78357121da8014a/537377ff73bdede7?lnk=gstq=family+tree#537377ff73bdede7 as a reference. the requirement at hand is to be abe to

[sqlalchemy] Declarative Base ID

2009-02-01 Thread vctr...@gmail.com
The ID field in a declarative base is a sequence that is not controled by the user (or is it?). Is there a way to get it to start the counting of the ID from 0 and not from 1? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[sqlalchemy] parent/child relationship: what am I doing wrong?

2009-02-01 Thread Kevin Dangoor
I've done many many-to-one relationships with SQLAlchemy, but there must be something obvious I'm doing wrong here: class Directory(Base): __tablename__ = directories id = Column(Integer, primary_key=True) name = Column(String, unique=True) subdirs = relation('Directory',

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Eric Ongerth
Kevin, the default behavior is for relations to be represented by lists. If what you want is a tree structure where a directory can only have a single parent, you would use backref=backref(parentdir, uselist=False). Or at least that's how you'd do it in plain SA; i haven't used the declarative

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Kevin Dangoor
On Sun, Feb 1, 2009 at 10:17 AM, Eric Ongerth ericonge...@gmail.com wrote: Kevin, the default behavior is for relations to be represented by lists. If what you want is a tree structure where a directory can only have a single parent, you would use backref=backref(parentdir, uselist=False).

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The syntax is basically same. Look at the standard documentation and examples for relation() and apply it to the decl layer. - -aj On 01.02.2009 16:17 Uhr, Eric Ongerth wrote: Kevin, the default behavior is for relations to be represented by

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Nebur
Kevin, did you already look at http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships ? By default, as the doc says, one-to-many is assumed. You want the backref (parentdir) to be a scalar, so you probably have to specify remote_side. Ruben

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Kevin Dangoor
Thanks for that link! It was late last night when I was looking at this and, embarrassingly enough, I hadn't gone to that particular section of the doc. Kevin On Sun, Feb 1, 2009 at 10:22 AM, Nebur t...@reifenberg.de wrote: Kevin, did you already look at

[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: mapping adjacency lists

2009-02-01 Thread Michael Bayer
please see http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships wrt the remote_side option and proper configuration of the many- to-one side of a self-referential relationship. On Feb 1, 2009, at 3:19 AM, n00b wrote: g'day, i wanted to give the adjacency pattern

[sqlalchemy] Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Piotrek Byzia
Hi, I'm a fresh user of SQLA, and this is my first attempt to use it. Based on the official tutorial example I created a many to many relation between two tables, but I have some issues with getting it working. It returns error Could not determine join condition between parent/child tables on

[sqlalchemy] Many-to-many realtion troubles

2009-02-01 Thread RusPython
#=== # I create many-to-many relation between A and B through ab_association table. # Then I create many-to-many relation between AB and C. # When I try to break relation between A and B objects I get next error: # #

[sqlalchemy] On delete cascade, set null

2009-02-01 Thread drakkan
Hi all, I have the following mapping: class SharesUsers(DeclarativeBase): __tablename__='m2m_shares_users' id=Column(Integer,autoincrement=True,primary_key=True) user_id=Column(Integer,ForeignKey ('samba_users.id',onupdate=CASCADE,ondelete=CASCADE),nullable=False)

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Michael Bayer
you're using homologues to link Protein_seed to PDB. so the two foreign keys should be between the tables named Proteins_seed and PDB, not Proteins_putative, which seems to be otherwise unmentioned here. On Feb 1, 2009, at 11:57 AM, Piotrek Byzia wrote: Hi, I'm a fresh user of

[sqlalchemy] Test and rollback transaction

2009-02-01 Thread GreyBadger
Hi, In an Exception catch block, one may or may not be sure if a transaction object has had begin() called. Is it safe to blindly call rollback() on a Transaction object, or is there a way to test if a transaction is active before calling rollback() (or indeed commit!). I couldn't find anything

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Piotrek Byzia
My fault, I haven't included Proteins_putative, PDB is just another table.. But anyway, the problem is with definition of many-to-many relaction() in Protein_seed. class Protein_putative(Base): __tablename__ = 'Proteins_putative' id = Column(Integer, primary_key=True) name =

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Michael Bayer
remove the secondary argument from proteins_seed to PDB, the homologues table has no relevance to that relation(). On Feb 1, 2009, at 1:56 PM, Piotrek Byzia wrote: My fault, I haven't included Proteins_putative, PDB is just another table.. But anyway, the problem is with definition of

[sqlalchemy] Re: Test and rollback transaction

2009-02-01 Thread Michael Bayer
somethings up with sphinxI rebuilt the docs locally since its not working on the server for some reason. doc is here: http://www.sqlalchemy.org/docs/05/reference/orm/sessions.html?highlight=active%20transaction#sqlalchemy.orm.session.Session.is_active On Feb 1, 2009, at 1:36 PM,

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Piotrek Byzia
Michael, Thanks for that hint! However, I still don't know how should I include association table 'homologues' relation :-( I sketched a schema of my DB: http://flickr.com/photos/piotrbyzia/3244490067/ and relevant code is under: http://pastie.org/376811 The similar problem is with

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-02-01 Thread Alessandro Dentella
stack trace you posted doesn't make sense to me though, as its issuing a SELECT statement but PG is raising an exception for an UPDATE / DELETE ? I've never seen that before. If you can provide a self- contained test case which reproduces that behavior we can try it out. Here is is.

[sqlalchemy] Re: Declaring a secondaryjoin in many to many relation.

2009-02-01 Thread Michael Bayer
On Feb 1, 2009, at 3:24 PM, Piotrek Byzia wrote: Michael, Thanks for that hint! However, I still don't know how should I include association table 'homologues' relation :-( I sketched a schema of my DB: http://flickr.com/photos/piotrbyzia/3244490067/ and relevant code is under:

[sqlalchemy] how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread rdmurray
I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes a month of '00', and sometimes the field's value is -00-00. The zeros are used to indicate don't know

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-02-01 Thread Michael Bayer
Here you go, its a psycopg2 bug. Familiarize yourself with the attached test case, then post it on the psycopg2 mailing list. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread Michael Bayer
Assuming these columns are ultimately CHAR or VARCHAR on the mysql side, build your own Date type using TypeDecorator in conjunction with the String type. MySQLdb's date/time functionality only takes effect for columns that are of the DATE, TIME or DATETIME columns. On Feb 1, 2009, at

[sqlalchemy] Re: Adding extra data to column objects

2009-02-01 Thread dgriffin
Ive seen some of the other stuff for generating forms but I want to do it myself. The info thing is exactly what I am looking for thanks. Dan On Feb 1, 1:53 am, a...@svilendobrev.com wrote: there has been a number of apps announced that do html forms from SA schema - look up the list. afaik

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread rdmurray
Quoth Michael Bayer mike...@zzzcomputing.com: Assuming these columns are ultimately CHAR or VARCHAR on the mysql side, build your own Date type using TypeDecorator in conjunction with the String type. MySQLdb's date/time functionality only takes effect for columns that are of the

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread Michael Bayer
so, MySQLdb itself cant read the columns ? is there a stack trace or anything ? SQLA passes date values straight through to Mysqldb. On Feb 1, 2009, at 6:31 PM, rdmur...@bitdance.com wrote: Quoth Michael Bayer mike...@zzzcomputing.com: Assuming these columns are ultimately CHAR or

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland
rdmur...@bitdance.com wrote: I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes a month of '00', and sometimes the field's value is -00-00. The zeros

[sqlalchemy] Understanding polymorphism

2009-02-01 Thread MikeCo
I have a single table polymorphism question. It looks like I can't directly set the value of the polymorphic discriminator when creating records; it is only set correctly when you instantiate objects of the derived class. Is that true? Why, or what is wrong here? Here is the scenario: Jobs have

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread rdmurray
Quoth jason kirtland j...@discorporate.us: rdmur...@bitdance.com wrote: I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes a month of '00', and

[sqlalchemy] Outer joins with ORM and single table polymorphism

2009-02-01 Thread MikeCo
I can't figure out how to write this outer join query in ORM-speak. Jobs have Steps; Steps have optional inputs of type SRC1, SRC2, or SRC3. Steps are stored in a single table with column kind as a discriminator. The existing legacy code uses a SELECT statement with outer joins to get the

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland
rdmur...@bitdance.com wrote: Quoth jason kirtland j...@discorporate.us: rdmur...@bitdance.com wrote: I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes a

[sqlalchemy] Re: Outer joins with ORM and single table polymorphism

2009-02-01 Thread MikeCo
Oops, the description should say Inputs are stored in a single table with column kind as a discriminator. On Feb 1, 10:58 pm, MikeCo mconl...@gmail.com wrote: I can't figure out how to write this outer join query in ORM-speak. Jobs have Steps; Steps have optional inputs of type SRC1, SRC2, or

[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: Understanding polymorphism

2009-02-01 Thread az
only the class owner of the identity sets it, internaly. i your case Input has no separate identity, but this does not give u right to set identity manualy. if it had, a=Input( whatver) would set that. or that's how i get it. On Monday 02 February 2009 04:15, MikeCo wrote: I have a single

[sqlalchemy] [SA0.5.2/PG] KeyError: pg_expression_2

2009-02-01 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there, using SA 0.5.2/Postgres 7.4.22. Reflecting an existing database gives me this: (Pdb) c /local/HRS2/Devel/junga/tb-dev/eggs/SQLAlchemy-0.5.2-py2.4.egg/sqlalchemy/engine/base.py:1265: SAWarning: Skipped unsupported reflection of