[sqlalchemy] Re: Problems with join query, can't figure out what's wrong. Noob alert!

2008-09-24 Thread Alex K
Hi, Try to replace .join(Prosjekt,Sak.prosjektid) with the .join(Prosjekt,Sak.prosjekt) in your first query and write back, Alex On 23 сент, 12:38, olavgg [EMAIL PROTECTED] wrote: I've recently started using SQLAlchemy and is a newb. I have good SQL knowledge though. My first project with

[sqlalchemy] Re: Relations - How?

2008-09-24 Thread Alex K
Hello, Actually, you can join on any condition, not only on the relation condition, In this case your query needs to evolve from: .outerjoin((ATranslation,Book.translations))\ to: .outerjoin((ATranslation, and_(ATranslation.book_id == Book.isbn,

[sqlalchemy] Re: Problems with join query, can't figure out what's wrong. Noob alert!

2008-09-24 Thread olavgg
Thank you for your answer, I did as you said but still returns the same error: InvalidRequestError: Mapper 'Mapper|Sak|sak' has no property 'class 'Products.TikkTakk.model.Prosjekt.Prosjekt'' --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: sorting by members

2008-09-24 Thread m.talaee
thanx alot it works On Sep 21, 2:05 am, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 20, 2008, at 7:59 AM, m.talaee wrote: hi all i need to sort users by number of theirfriends. there is many to many relation table between user table and itself. order_by don't support ordering (or i

[sqlalchemy] cascade defaults

2008-09-24 Thread az
hi i have cascade= option of relation switched automaticaly between all and other values, and nothing. so i used cascade=None as nothing, hoping it will get the default behaviour. the result was some query got 6x slower (actualy thats why i went hunting it)... nope, it happens that

[sqlalchemy] Limit to 500 records after particular date.

2008-09-24 Thread Heston James - Cold Beans
Morning Guys, I hope this'll be a fairly simple question. I have a query which looks something like this: the_objects = session.query(myobject.myobject).filter(myobject.created :lastrecord).params(lastrecord=time.strftime(%Y-%m-%d %H:%M:%S, from_date)).all() This grabs all the records

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread az
first u get your query sorted in proper order (by timestamp or even dbid, or hierarchicaly via subselect + groupby + order, whatever) then yourquery[:1000] On Wednesday 24 September 2008 14:11:24 Heston James - Cold Beans wrote: Morning Guys, I hope this'll be a fairly simple question.

[sqlalchemy] Re: Problems with join query, can't figure out what's wrong. Noob alert!

2008-09-24 Thread Alex K
K, seems that I've found the root cause: When you are making the join from query, the syntax is: app.session.query(Sak).join(Sak.prosjektid).filter( where Sak.prosjektid is the relation property of the Sak class or you can specify the target in the tuples form:

[sqlalchemy] Re: Problems with join query, can't figure out what's wrong. Noob alert!

2008-09-24 Thread olavgg
Thank you again for a good answer. I still can't figure this out though, Im getting the same error message all the time when I use .join() Could it be an issue with Elixir which I'm using? Or with Plone/Five? What about just using a from_statement? On Sep 24, 3:16 pm, Alex K [EMAIL PROTECTED]

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Heston James
Hi, Thanks for the response, that gave me a good foot in the door to this. I've now appened my existing query with. .order_by('myobject.created')[:1000] Which appears to give the desired result set, however, when looking through the SQL debug output it seems that the limit their is applied

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Werner F. Bruhin
Heston, Heston James wrote: Hi, Thanks for the response, that gave me a good foot in the door to this. I've now appened my existing query with. .order_by('myobject.created')[:1000] Just tried this on a simple example: query = query.limit(500) Quote from doc for 0.5rc1: *def

[sqlalchemy] Re: Fwd: Support for ordered lists of child items

2008-09-24 Thread jason kirtland
Emmett Lazich wrote: Thank you Jason. orderinglist looks like what I am after! Is your orderinglist plugin fully functional in 0.4.7p1? Yep. Before I attempt it, pls advise if there any technical reason preventing the integration of orderinglist into the basic_tree.py (adjacency list)

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Heston James
Werner, Thank you for your response, very kind of you. This looks to be more what I'm looking for, after a quick test it seems that it is now applying the limit at the SQL level which is definitly a good thing. Where abouts in the documentation did you find that? Look here:

[sqlalchemy] Re: Cyclic references and Nullable

2008-09-24 Thread mraer
Thank you - i think it is a solution SA's Constraint types have support for generating a deferrable key at CREATE TABLE table: http://www.sqlalchemy.org/docs/05/sqlalchemy_schema.html#docstrings_s... I believe you can either define the cyclic constraints as initially deferred for this

[sqlalchemy] Re: Performance problem related to saving newly created objects.

2008-09-24 Thread Randallabra
Awesome! Thank you very much indeed for the follow-up. After turning of expire_on_commit, saving a newly created object takes less than 1/3 of a second even with 100K objects in memory. It's always nice to find the fast = True switch. :-) On Sep 23, 6:00 pm, Michael Bayer [EMAIL PROTECTED]

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Werner F. Bruhin
Heston, Heston James wrote: Werner, Thank you for your response, very kind of you. This looks to be more what I'm looking for, after a quick test it seems that it is now applying the limit at the SQL level which is definitly a good thing. Where abouts in the documentation did you find

[sqlalchemy] Is the string 'version' a reserved word or not usable in relations in SA?

2008-09-24 Thread Randallabra
There is a case in my application where setting the attribute 'version' which is the name of a relationship to a look up table. When I avoid setting this attribute, saving the record takes 0.15s, however when I set the value of this relationship, saving the record takes upwards of 30 seconds.

[sqlalchemy] Re: Is the string 'version' a reserved word or not usable in relations in SA?

2008-09-24 Thread Randallabra
Replying to my own post: It appears that I've resolved this problem by removing the reciprocal relationship (backref) from this particular relation. Though it is a bit of a head-scratcher as to why the removal of the backref resolves the circular dependency problem given that this table has many

[sqlalchemy] column renaming and adding

2008-09-24 Thread Wim Verhavert
I have a setup like this: class Entity(object): pass class Persoon(Entity): pass entity_tabel = Table('contact', metadata, Column('contactid', Integer, primary_key=True), Column('voornaam', String(75)),

[sqlalchemy] Re: Problems with join query, can't figure out what's wrong. Noob alert!

2008-09-24 Thread Alex K
I've never used Elixir/Plone, I'll try you example with Elixir tomorow and will let you know. On 24 сент, 18:27, olavgg [EMAIL PROTECTED] wrote: Thank you again for a good answer. I still can't figure this out though, Im getting the same error message all the time when I use .join() Could it

[sqlalchemy] Newbie many-to-many using Declarative question

2008-09-24 Thread Doug Farrell
Hi all, I'm trying to set up a many-to-many system using the Declarative syntax against an existing MySQL set of tables. We're using a 'link' table between two other tables we want to relate many-to-many. Here's the simplified layout of those tables: mysql desc press_routing_press;

[sqlalchemy] Re: cascade defaults

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 6:23 AM, [EMAIL PROTECTED] wrote: hi i have cascade= option of relation switched automaticaly between all and other values, and nothing. so i used cascade=None as nothing, hoping it will get the default behaviour. the result was some query got 6x slower (actualy thats

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 11:02 AM, Heston James wrote: Hi, Thanks for the response, that gave me a good foot in the door to this. I've now appened my existing query with. .order_by('myobject.created')[:1000] Which appears to give the desired result set, however, when looking through the

[sqlalchemy] Re: Cyclic references and Nullable

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 12:11 PM, jason kirtland wrote: SA's Constraint types have support for generating a deferrable key at CREATE TABLE table: http://www.sqlalchemy.org/docs/05/sqlalchemy_schema.html#docstrings_sqlalchemy.schema_Constraint I believe you can either define the cyclic

[sqlalchemy] Re: Is the string 'version' a reserved word or not usable in relations in SA?

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 2:16 PM, Randallabra wrote: Replying to my own post: It appears that I've resolved this problem by removing the reciprocal relationship (backref) from this particular relation. Though it is a bit of a head-scratcher as to why the removal of the backref resolves the

[sqlalchemy] Re: Newbie many-to-many using Declarative question

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 5:19 PM, Doug Farrell wrote: class PressRoutingPress(Base): '''This class defines the many-to-many join table between press and press_routing. ''' __tablename__ = press_routing_press __table_args__ = {'autoload' : True} press_id = Column(Integer,

[sqlalchemy] Unicode Results from SQL functions

2008-09-24 Thread Shawn Church
I am trying to construct a select query in mysql (version 5.0.51a-3ubuntu5.3-log) using SQL functions. Once I set the convert_unicode flag = True on my engine some function results are returned as type str and some results are returned as type unicode (I want, and expected, all unicode).

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 10:13 PM, Shawn Church wrote: I am trying to construct a select query in mysql (version 5.0.51a-3ubuntu5.3-log) using SQL functions. Once I set the convert_unicode flag = True on my engine some function results are returned as type str and some results are

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Shawn Church
On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer [EMAIL PROTECTED]wrote: we can of course add more functions to the list of known functions such as ifnull() (it would be best if ifnull() is a SQL standard function, I'm not sure if it is). Not sure this will work for IFNULL since it's type

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread jason kirtland
Shawn Church wrote: On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: we can of course add more functions to the list of known functions such as ifnull() (it would be best if ifnull() is a SQL standard function, I'm not sure