[sqlalchemy] SA 0.3.4 and sequence for non-primary key column

2007-02-02 Thread che
Hi, I have a table with column that must use sequence generated number (for example in Postgres), like this obj_id: table_Manager = Table( 'Manager', meta, Column( 'obj_id', Integer, Sequence('obj_id_seq'), ), Column( 'duties', type= String, ), Column( 'name', type=

[sqlalchemy] Left Joins and Improper Parenthesis when Building Query Expressions

2007-02-02 Thread jlowery
I am building a SQL query one step at a time in different parts of my application. I am using MySQL 4.1 Currently, the query being automatically built is: (SELECT doc_index.doc_id, doc_index.doc_type, doc_index.ref_id, doc_index.create_date, doc_index.modified_date FROM doc_index) JOIN snack

[sqlalchemy] Re: Left Joins and Improper Parenthesis when Building Query Expressions

2007-02-02 Thread svilen
stmt = doc_type_table.select() join_table = get_join_table('widgets') stmt = stmt.join(join_table, SA.and_(doc_type_table.c.ref_id==join_table.primary_key[0], doc_type_table.c.doc_type=='widgets')) join_table2 = get_join_table('spam') stmt = stmt.join(join_table2,

[sqlalchemy] Re: Tool to check whether DB matches model

2007-02-02 Thread Paul Johnston
Hi, Well, I just happened to say model in my original message. I could have said Tool to check whether a bunch of SA tables matches the database tables. That is what model_update.py does (at least, it tries to!) - so is it something you'd consider including as an SA plugin? Paul On 2/1/07,

[sqlalchemy] what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
hallo. AFAI understand from the source, in the graph used for topology sorting in session.flush(), the nodes are representing the objects' mappers. (and not the tables as in metadata.create_all() ). Also, mappers which inherit from others, are replaced by their bases/roots. Edges in the

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
i am asking this, because so far i am considering both table/foregn-key graph and mapper/relation graph same, thus applying the mincut for the table/foregnkey (which sets fkey.use_alter=True) also to the other (which sets respective relation.post_update=True). And in 99% of cases, this works.

[sqlalchemy] Re: Left Joins and Improper Parenthesis when Building Query Expressions

2007-02-02 Thread Michael Bayer
a join() by itself shouldnt be executed. you need to call select() off of it (or use it inside the from_obj param of another select()). notice its not the parenthesis that are the problem, its the lack of an enclosing SELECT ... FROM. On Feb 2, 5:04 am, jlowery [EMAIL PROTECTED] wrote: I am

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
a circular relationship between two mappers means that a dependency sort revealed that the mapper-level dependency graph contains cycles. that portion of the sort is then thrown away and replaced with a dependency sort where the nodes are individual object instances. so sort #1 is mappers as

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
A mincut algorithm finds the minimal number of edges to cut in a cycled graph so it becomes without cycles. http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem i.e. applying such algorithm over the graph of table dependencies (foregnkey), one gets some minimal number of foreign keys to make

[sqlalchemy] Re: Left Joins and Improper Parenthesis when Building Query Expressions

2007-02-02 Thread Michael Bayer
As I understand the confusion here, Ive added a check for supports execution in rev 2289. so that when you try to execute the join, it will raise an error. originally i wasnt sure what would be executable and what would not but im hoping its pretty well nailed down at this point. so far its:

[sqlalchemy] Re: SQLAlchemy + MySQL encoding error (probably wrong charset=... handling)

2007-02-02 Thread Michael Bayer
On Feb 2, 2007, at 2:49 AM, Andrew Stromnov wrote: cities = cities.select(limit=1).execute().fetchall() works well with this configuration, but leads to error in nregion = places.select(places.c.name == iv2).execute() if nregion = places.select(places.c.name == iv2).execute() used first,

[sqlalchemy] Re: SQLAlchemy + MySQL encoding error (probably wrong charset=... handling)

2007-02-02 Thread Andrew Stromnov
On 2/2/07, Michael Bayer [EMAIL PROTECTED] wrote: are you saying that executing a particular statement is changing some state on the local connection ? Not exactly what I had in mind. Execution of first appeared statement assigns (underlying ?) charset for all following queries for all

[sqlalchemy] Re: Full Text Search using PostgreSQL and tsearch2

2007-02-02 Thread Dennis
I have site in production right now that is using tsearch2. What I did to accommodate the results with SA was to simply not map the tsearch2 column to the SA object. I have a view that creates the tsvector objects based on the source table. (I actually created a materialized view and indexed

[sqlalchemy] Re: SA 0.3.4 and sequence for non-primary key column

2007-02-02 Thread Michael Bayer
thats a bug, i fixed it in r2291. if you dont want to use the trunk for now, you can probably define the column as: Column('obj_id', integer, default=func.obj_id_seq.nextval()) On Feb 2, 2007, at 4:05 AM, che wrote: Hi, I have a table with column that must use sequence generated number

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
On Feb 2, 2007, at 10:33 AM, svilen wrote: A mincut algorithm finds the minimal number of edges to cut in a cycled graph so it becomes without cycles. http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem i.e. applying such algorithm over the graph of table dependencies (foregnkey), one

[sqlalchemy] Re: SQLAlchemy + MySQL encoding error (probably wrong charset=... handling)

2007-02-02 Thread Michael Bayer
right, except that when you say statement1.execute() and then statement2.execute(), its very likely that those two statements are using distinct connections from the connection pool. also, SA is not issuing any kind of charset anything on a connection so it would not be within SA's

[sqlalchemy] Re: SA 0.3.4 and sequence for non-primary key column

2007-02-02 Thread che
Hi, Michael Bayer написа: if you dont want to use the trunk for now, you can probably define the column as: Column('obj_id', integer, default=func.obj_id_seq.nextval()) this answers another question of mine :) that i planned to ask ...but it generates (on Postgres) this: SELECT

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
i think you are looking for a feedback arc set, which describes exactly the problem that applying post_update to a mapping solves: http://en.wikipedia.org/wiki/Feedback_arc_set and we actually generate a set like this in the _find_cycles() method, except it doesnt find just one edge of

[sqlalchemy] Re: Tool to check whether DB matches model

2007-02-02 Thread Michael Bayer
oh sure, if not on the wiki directly of course it can linked/ downloaded/whatever from the site...id like to have as many recipes and things as possible (which is really what the wiki is for).if it were with the dist, id have it in a util or contrib folder off the root. On Feb 2,

[sqlalchemy] Re: SA 0.3.4 and sequence for non-primary key column

2007-02-02 Thread Michael Bayer
oh right...try func.nextval('obj_id_seq') On Feb 2, 2007, at 12:46 PM, che wrote: Hi, Michael Bayer написа: if you dont want to use the trunk for now, you can probably define the column as: Column('obj_id', integer, default=func.obj_id_seq.nextval()) this answers another question of

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
On Feb 2, 2007, at 2:14 PM, svilen wrote: of course, topological sort is a sort, but in order of it to work, the graph should not have cycles. Which are cut by use_alter's and post_updates, on foreign keys and relations. well, in our case all edges have cost of 1, except

[sqlalchemy] Unit testing with SA?

2007-02-02 Thread Allen
Sorry for the rather newbie question, but I can't find anything about this anywhere else. How do people writing db applications with SA do unit testing on their code? Are there any good db unit testing frameworks that work well with SA? If I can't find anything I will probably just roll my own

[sqlalchemy] Re: Unit testing with SA?

2007-02-02 Thread Christopher Arndt
Allen schrieb: How do people writing db applications with SA do unit testing on their code? Are there any good db unit testing frameworks that work well with SA? If I can't find anything I will probably just roll my own but I would like to keep from reinventing the wheel if I can help it.