[sqlalchemy] Re: passive deletes

2011-08-12 Thread erikj
Hello Michael, thank you for your answer. You are right that this behavior can be enforced by setting the viewonly attribute of the relation, and the others are not needed. However, I do need to set it on both sides of the relation, or it does not work. But this not working might be triggered

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread NiL
Hi, thank you for your help, and the effort at writing a good piece of code. however, while playing around with, and trying to execute it in PGAdmin, I stumbled upon some problems the q = Session().query(Group).join(all_parents, all_parents.c.id==Group.id) generates a SQL like (I've

[sqlalchemy] Can pk_col function be adapted for Firebird?

2011-08-12 Thread werner
I can't figure out how I could adapt the pk_col function on this page http://www.sqlalchemy.org/trac/wiki/UsageRecipes/NamingConventions to handle the Sequence definition needed for e.g. Firebird. At the point when Column is instantiated I don't have access to table.name and I can't figure it

[sqlalchemy] Simple select is really slow when executed via ORM

2011-08-12 Thread Massi
Hi everyone, I'm doing some test to evaluate the performance of querying with sqlalchemy via ORM. I wrote a simple script to measure the execution time of a simple select query made on relatively small table (300 000 records, 6 columns) in sqlite. Here is the script: from sqlalchemy import *

Re: [sqlalchemy] Can pk_col function be adapted for Firebird?

2011-08-12 Thread werner
On 08/12/2011 02:18 PM, werner wrote: I can't figure out how I could adapt the pk_col function on this page http://www.sqlalchemy.org/trac/wiki/UsageRecipes/NamingConventions to handle the Sequence definition needed for e.g. Firebird. At the point when Column is instantiated I don't have

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread Michael Bayer
On Aug 12, 2011, at 6:00 AM, NiL wrote: Hi, thank you for your help, and the effort at writing a good piece of code. however, while playing around with, and trying to execute it in PGAdmin, I stumbled upon some problems the q = Session().query(Group).join(all_parents,

[sqlalchemy] Softcoding .filter(...)

2011-08-12 Thread RVince
I'm trying to discern a means of creating a .filter(A rel B) where the values for A, rel and B come from an parameters passed in to the web page. I already have an SQLAlchemy statement, say query = Session.query(table).filter(A==B) and I want to be able to allow for a drilldown of sorts by the,

Re: [sqlalchemy] Relationship spanning on multiple tables

2011-08-12 Thread Michael Bayer
On Aug 11, 2011, at 6:45 PM, neurino wrote: Sorry if I bother again but adding some others relationships like this spanning on 5 tables: mapper(UserLayer, inherits=base_user_layer_mapper, polymorphic_identity=CLASS_LAYER, properties={ ...

Re: [sqlalchemy] Softcoding .filter(...)

2011-08-12 Thread Mark Erbaugh
On Aug 12, 2011, at 10:21 AM, RVince wrote: I'm trying to discern a means of creating a .filter(A rel B) where the values for A, rel and B come from an parameters passed in to the web page. I already have an SQLAlchemy statement, say query = Session.query(table).filter(A==B) and I want

Re: [sqlalchemy] Simple select is really slow when executed via ORM

2011-08-12 Thread Michael Bayer
Here's a comparison that begins to be slightly fair regarding the work of fetching raw rows versus generating and identity-managing full object rows. On my mac the SQL query takes 7 seconds and the Session query 13.7, so twice as slow, rather than 20. The difference is we are actually

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread NiL
hi again, after playing a while with PG, here is a SQL statement that outputs the expected result SELECT groups_recursive.id AS groups_recursive_id, groups_recursive.name AS groups_recursive_name, groups_recursive.display_name AS groups_recursive_display_name FROM groups_recursive JOIN (WITH

Re: [sqlalchemy] Can pk_col function be adapted for Firebird?

2011-08-12 Thread Michael Bayer
On Aug 12, 2011, at 9:04 AM, werner wrote: On 08/12/2011 02:18 PM, werner wrote: I can't figure out how I could adapt the pk_col function on this page http://www.sqlalchemy.org/trac/wiki/UsageRecipes/NamingConventions to handle the Sequence definition needed for e.g. Firebird. At the

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread Michael Bayer
sure, couple of small adjustments, attached On Aug 12, 2011, at 10:44 AM, NiL wrote: hi again, after playing a while with PG, here is a SQL statement that outputs the expected result SELECT groups_recursive.id AS groups_recursive_id, groups_recursive.name AS groups_recursive_name,

Re: [sqlalchemy] Can pk_col function be adapted for Firebird?

2011-08-12 Thread werner
On 08/12/2011 04:46 PM, Michael Bayer wrote: On Aug 12, 2011, at 9:04 AM, werner wrote: On 08/12/2011 02:18 PM, werner wrote: I can't figure out how I could adapt the pk_col function on this page http://www.sqlalchemy.org/trac/wiki/UsageRecipes/NamingConventions to handle the Sequence

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread NiL
thank you so much Michael !! much better few last things are WITH RECURSIVE all_parents(id, rank) AS SELECT groups_recursive.id, 1 FROM groups_recursive, groups_recursive_parents__groups_recursive_children quotes around the 1, this leads to ERROR: column 1 does not exist + the param

[sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread RVince
Mark, yes, in part. What I cannot figure out -- and am not sure this is possible with SQLAlchemy, is to go from strings, as returned from HTTP Post's, representing the fields in the table (for the left side of the relation) to the actual statemetn itself. In other words, if the HTTP post calls for

[sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread NiL
say you want to filter on the 'field' (field would be a string representing the name of the field) on objects of class == Klass field_attr = getattr(Klass, field) would give you the instrumented attribute then Session.query(Klass).filter(field_attr == searchString) or

Re: [sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread Mark Erbaugh
On Aug 12, 2011, at 11:52 AM, NiL wrote: say you want to filter on the 'field' (field would be a string representing the name of the field) on objects of class == Klass field_attr = getattr(Klass, field) would give you the instrumented attribute then

Re: [sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread Wichert Akkerman
On 08/12/2011 05:52 PM, NiL wrote: say you want to filter on the 'field' (field would be a string representing the name of the field) on objects of class == Klass field_attr = getattr(Klass, field) would give you the instrumented attribute then Session.query(Klass).filter(field_attr ==

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread Michael Bayer
its at the point where you should be able to tweak it using documented processes. column() applies quotes for example, whereas literal_column(1) would not. Same for an expression x + 1 will turn the 1 into a bind, would not if you again use literal_column()

[sqlalchemy] bulk selection

2011-08-12 Thread Eduardo
Dear All, I have a list of elements for which I need to establish if they are in a tadabase. I can make for each element a separate query but I am afraid that that is not the best approach what is the best practice in this case? Thanks -- You received this message because you are subscribed to

Re: [sqlalchemy] joining to a from_statement

2011-08-12 Thread NiL
yes, many thanks I now have a method in my Group class (still in elixir syntax) def hierarchy_ng(self): with CommonTableExpression.create( all_parents, [id, rank]) as all_parents: rank = literal_column(rank) groups = Group.table groups_assoc =

[sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread RVince
Wickert, can you give me an example ? I'm a little confused by this posts of yours. RVince On Aug 12, 12:20 pm, Wichert Akkerman wich...@wiggy.net wrote: On 08/12/2011 05:52 PM, NiL wrote: say you want to filter on the 'field' (field would be a string representing the name of the field)

[sqlalchemy] Re: Softcoding .filter(...)

2011-08-12 Thread RVince
Thanks to all you guys. Really. I didn't think I would be able to do this! RVince -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] group_by argument as a result of a query

2011-08-12 Thread Eduardo
Dear all, I am trying to limit group_by function only on the rows that satisfy certain query if I use group_by(table.c.something) this pertains to whole table. I tried to use elements of the tuple rendered as a result of a query as arguments (as it has been suggested on this forum) but it did not

[sqlalchemy] The capacity of the session

2011-08-12 Thread Eduardo
Dear all, How can I determine the number of objects (the memory capacity) that a session can take? How can I determine the size of an object? Thanks -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

Re: [sqlalchemy] bulk selection

2011-08-12 Thread Mariano Mara
On 12.08.11 09:41, Eduardo wrote: Dear All, I have a list of elements for which I need to establish if they are in a tadabase. I can make for each element a separate query but I am afraid that that is not the best approach what is the best practice in this case? Thanks Depending on the

Re: [sqlalchemy] group_by argument as a result of a query

2011-08-12 Thread Michael Bayer
can you please illustrate a simple SQL statement that illustrates what you are trying to achieve ? On Aug 12, 2011, at 1:00 PM, Eduardo wrote: Dear all, I am trying to limit group_by function only on the rows that satisfy certain query if I use group_by(table.c.something) this pertains

Re: [sqlalchemy] The capacity of the session

2011-08-12 Thread Michael Bayer
I'm not familiar with any method for doing that, and it depends mostly on how much data each of your objects contains - the Session/ORM will have a small amount of memory overhead beyond that which is of a fixed size. At best I'd say you can estimate the memory size per object by running a

[sqlalchemy] declarative __table__ columns

2011-08-12 Thread Mark Erbaugh
Is there a way to access the parameters to the Column() call used to set up a database table when given either an instance field or class field? For example: class MyClass(Base): ... f1 = Column(Integer, nullable=False, info={'min':0}) ... If I have MyClass.f1 or

Re: [sqlalchemy] declarative __table__ columns

2011-08-12 Thread Michael Bayer
On Aug 12, 2011, at 5:05 PM, Mark Erbaugh wrote: Is there a way to access the parameters to the Column() call used to set up a database table when given either an instance field or class field? For example: class MyClass(Base): ... f1 = Column(Integer, nullable=False,

Re: [sqlalchemy] declarative __table__ columns

2011-08-12 Thread Mark Erbaugh
On Aug 12, 2011, at 5:26 PM, Michael Bayer wrote: Is there a way to access the parameters to the Column() call used to set up a database table when given either an instance field or class field? For example: class MyClass(Base): ... f1 = Column(Integer, nullable=False,

[sqlalchemy] string concatentation of multiple columns in select statement

2011-08-12 Thread nospam
I'm trying to do something like this in sqlalchemy: select (score/10)*10 || '-' || (score/10)*10+9 as scorerange, count(*)from scoresgroup by score/10 order by 1 which should give: scorerange | count +--- 0-9|11 10-19 |14 20-29 | 3 30-39 | 2

Re: [sqlalchemy] string concatentation of multiple columns in select statement

2011-08-12 Thread Michael Bayer
On Aug 12, 2011, at 6:43 PM, nospam wrote: I'm trying to do something like this in sqlalchemy: select (score/10)*10 || '-' || (score/10)*10+9 as scorerange, count(*)from scoresgroup by score/10 order by 1 which should give: scorerange | count +--- 0-9|11