[sqlalchemy] query - automatic lazy attribute expiration

2009-03-04 Thread ml
Hi! Is it possible to force query to automatically expire instance's lazy attributes? And I mean instances that were queried and accessed before the second query? Example: mapper(MyObject, my_table, properties={ myattr: relation(ChildObject) }) following code will lead in only 3 SELECTs

[sqlalchemy] Re: Query variable outerjoin()

2009-01-08 Thread ml
this is what I'm looking for but it doesn't work in 0.4.8. 0.5 is fine? Michael Bayer napsal(a): do you perhaps mean to say, query(Sortment).outerjoin((Translation, and_(Sortiment.id==Translation.sortiment_id, Translation.langauge=='en'))) ? On Jan 7, 2009, at 4:04 PM, ml wrote

[sqlalchemy] Query variable outerjoin()

2009-01-07 Thread ml
Hi! I have 2 tables: sortiment(id, ...) translations(id, id_sortiment, language, text) The query query(Sortiment).outerjoin(Sortiment.translations).filter(Translation.language=en) will never return sortiment item with missing en translation because the filter (useless outerjoin). I need

[sqlalchemy] Re: Query variable outerjoin()

2009-01-07 Thread ml
That is a solution but it is not very efficient. It involves a sequential scanning of the result of the join inside the database. Michael Bayer napsal(a): On Jan 7, 2009, at 11:49 AM, ml wrote: Hi! I have 2 tables: sortiment(id, ...) translations(id, id_sortiment, language

[sqlalchemy] Re: error when running query.count()

2008-08-28 Thread ml
Of ml Sent: Wednesday, August 27, 2008 2:09 AM To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: error when running query.count() Hi! There are more than 1 mapper to an object. Send your mappers configuration. David mkhan napsal(a): Hi, I am trying get a count for a query

[sqlalchemy] Re: error when running query.count()

2008-08-27 Thread ml
Hi! There are more than 1 mapper to an object. Send your mappers configuration. David mkhan napsal(a): Hi, I am trying get a count for a query but it errors out with following message: Page handler: bound method Root.index of harvest.controllers.Root object at 0x018444B0 Traceback

[sqlalchemy] Re: disable polymorphic load

2008-08-26 Thread ml
thats a bug which was fixed post 0.4.7p1. Its in trunk and is for 0.4.8. Great! And back to the mapper properties. As I found it always do a polymorphic_fetch=select-like query when dealing with mapper properties referencing a polymorphic base. This is not very efficient. I would prefer an

[sqlalchemy] disable polymorphis load

2008-08-25 Thread ml
Hi! How can I disable a polymorphic load for a single query? I found a hint in http://markmail.org/message/2kwbm377j3pdvvqb but I can't find more. Thanks for any advice. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[sqlalchemy] Re: disable polymorphis load

2008-08-25 Thread ml
, 2008, at 10:35 AM, ml wrote: Hi! How can I disable a polymorphic load for a single query? I found a hint in http://markmail.org/message/2kwbm377j3pdvvqb but I can't find more. Thanks for any advice. David --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: disable polymorphis load

2008-08-25 Thread ml
, at 11:24 AM, ml wrote: This is not working: Setup: base = Table(base, metadata, Column(id, Integer, primary_key=True), Column(kind, Integer), ) derived = Table(derived, metadata, Column(id, Integer

[sqlalchemy] Re: disable polymorphic load

2008-08-25 Thread ml
. if you're depending heavily on inheritance I strongly recommend looking at 0.5, this is one area where a significant amount of work has been done. On Aug 25, 2008, at 11:24 AM, ml wrote: This is not working: Setup

[sqlalchemy] Re: disable polymorphic load

2008-08-25 Thread ml
inherit_condition=derived.c.id==base.c.id or inherit_condition=base.c.id==derived.c.id But why? Is my inherit_condition incorrect at all? The example code is attached. Michael Bayer napsal(a): On Aug 25, 2008, at 1:05 PM, ml wrote: One more thing :-) Now I have polymorphic_fetch=deferred

[sqlalchemy] Re: Query to get all items from a table which have no reference to another table?

2008-08-25 Thread ml
Hi! Or something like s.query(A).filter(not_(A.column.in_(select(table_b.c.column)) David Empty napsal(a): Hello Felix, No I want to get all items from table A where no matching item in table B exists. I'm aware that this would be very easy if table A stores the foreign key.

[sqlalchemy] embedding aggregates into query or mapper

2008-06-19 Thread ml
Hi! Let's have a typical schema: Company - Employee How can I add a scalar column (in a query or a mapper) to the Company containing the employees count? E.g. query(Company).all() will return list of Company instances and each will have an extra property with emloyees count. But I don't want

[sqlalchemy] inverted in_

2008-06-16 Thread ml
Hi! How can I invert the in_ operator? I need a select like: ... name NOT IN ('alice', 'bob')... ...filter(not User.name.in_('alice', 'bob'))... is not working. Thanks for advices. David --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] polymorphism without extra table

2008-06-10 Thread ml
Hi! I have following situation: I have 3 tables which stand as a base for other stuff: table_virtual_categories = Table(virtual_categories, meta, Column(id, Integer, primary_key = True), Column(id_parent, Integer, ForeignKey(virtual_categories.id)), Column(visible, Boolean,

[sqlalchemy] Re: polymorphism without extra table

2008-06-10 Thread ml
that's it! great, thanks! Michael Bayer napsal(a): On Jun 10, 2008, at 8:34 AM, ml wrote: So as you can see the table articles is quite redundant because it has only the primary key column but I didn't find any other way to select articles directly from the table virtual_items

[sqlalchemy] Re: Sqlalchemy and py2exe...

2007-05-30 Thread ml
Hi! Just put somewhere an explicit import sqlite. It should be enough. David pdamoc napsal(a): Hello, I've tried packing an app I've made with py2exe and run into trouble... first it was an EGG issue, I've fixed that installing everything as a directory next came the sqlite issue... I

[sqlalchemy] Re: Could not assemble any primary key columns for mapped table

2007-05-07 Thread ml
That's it, thanks! Michael Bayer napsal(a): On May 4, 2007, at 9:17 AM, ml wrote: Hi! I have a few tables with non-integer primary keys. Following raises an exception: meta = MetaData(name=somemeta) themes = table(themes, meta, Column(title, Unicode(30), primary_key=True

[sqlalchemy] Re: multiple M:N joins fails

2007-05-04 Thread ml
Michael Bayer napsal(a): On May 1, 2007, at 4:42 AM, ml wrote: I want to get recipes which belongs to a particular category and having a particular flag. So I need both joins recipe-category and recipe- flag. ah. in that case you dont want query.join(x).join(y), you want

[sqlalchemy] Re: multiple M:N joins fails

2007-05-01 Thread ml
I want to get recipes which belongs to a particular category and having a particular flag. So I need both joins recipe-category and recipe-flag. Michael Bayer napsal(a): On Apr 30, 2007, at 8:40 AM, ml wrote: Hi! I have 2 relations: - recipes-categories (M:N) - recipes-flags (M:N

[sqlalchemy] Re: SQLAlchemy 0.3.7 released

2007-04-30 Thread ml
Excellent! Michael Bayer napsal(a): 0.3.7 is out and has a huge number of improvements and fixes. some of the highlights: - server side cursor support for Postgres - much improved auto-reconnect support - informix support - long identifier name support - support for unicode

[sqlalchemy] multiple M:N joins fails

2007-04-30 Thread ml
Hi! I have 2 relations: - recipes-categories (M:N) - recipes-flags (M:N) I'd like to get something like: SELECT recipes.title FROM recipes JOIN _recipes_ctgs_recipes ON _recipes_ctgs_recipes.id_recipe = recipes.id JOIN recipes_ctgs ON

[sqlalchemy] Re: distinct doesn't work with join

2007-04-29 Thread ml
Thanks! How stable is this revision? Is it suited for production? Michael Bayer napsal(a): OK r2579 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: apache, engine and metadata

2007-04-23 Thread ml
2) the number of connections to the db growing ... is implemented well the MetaData() class ? I'm using postgresql schema's and I want to mantain a single connection for every db user. Hi! I had the same problem because I was calling create_engine in every page request (apache +

[sqlalchemy] Re: order_by

2007-04-16 Thread ml
e.g. order_by = [desc(table1.mycol)] Disrupt07 napsal(a): In my table I have a column with type Boolean. When using order_by on this column I am getting the results as follows: False False True True True ... True I want them the other way round (the True first, then the False).

[sqlalchemy] Re: selecting from M:N via secondary table's column

2007-04-16 Thread ml
How can I select user's addresses when I know only his id? And I don't want to select the user first. session.query(Address).join(user).select(User.c.id==the user id) I was afraid of that :-) I hoped it can go in a cleaner way like join(Address.c.user) but giving the property as a

[sqlalchemy] selecting from a relation

2007-04-12 Thread ml
Hi! Lets have: ## users_table = Table(users, metadata, Column(id, Integer, primary_key=True), Column(user_name, String(16)) ) addresses_table = Table(addresses, metadata, Column(id, Integer, primary_key=True), Column(id_user, Integer, ForeignKey(users.id)),

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread ml
See attachment. Tested against 0.3.6. Michael Bayer napsal(a): On Apr 12, 2007, at 12:53 PM, ml wrote: I tried s.query(Address).select_by(user=u) as I found similar in the documentation (http://www.sqlalchemy.org/docs/ datamapping.html#datamapping_selectrelations_relselectby) but SA

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread ml
I'm such a moron. I downloaded the SA source into a sqlalchemy3 directory but the SA expects it in a sqlalchemy package so it was internaly loading the old 0.2.8 Ubuntu version. Sorry! :-) Michael Bayer napsal(a): On Apr 12, 2007, at 12:53 PM, ml wrote: I tried s.query(Address).select_by

[sqlalchemy] strange reference (appending to children)

2007-04-04 Thread ml
Hi! I found a quite strange behavior. Reproduction is simple. Setup: selfref=Table(selfref, metadata, Column(id,Integer, primary_key=True), Column(id_par,Integer, ForeignKey(selfref.id)) ) class SelfRef(object):pass mapper(SelfRef, selfref, properties={

[sqlalchemy] print SQL only

2007-03-30 Thread ml
Hi! I want meta.create_all() to generate and print the SQL only and don't query the DB. Is there any way? Thanks for advices. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] constants in strings

2007-01-01 Thread ml
Hi! Just for curiosity: why sqlalchemy is using constants in strings? E.g.: cascade = all, delete-orphan Why not something like: cascade = ALL | DELETE_ORPHAN I'm asking because I realized that when I make a mistake in the string the sqlalchemy doesn't report anything and my program crashes

[sqlalchemy] Re: SQLAlchemy and py2exe problem

2006-12-19 Thread ml
Hi! I had similar problem with module postgres. py2exe didn't automaticaly include the module so I simply put import sqlalchemy.databases.postgres into the main script. Perhaps you should try something like this with the logging. DS Karlo Lozovina píše v Út 19. 12. 2006 v 04:01 +: Hi

[sqlalchemy] value too long for type character varying

2006-12-18 Thread ml
Hi! Can I force SA (0.2.8) to ignore the sqlalchemy.exceptions.SQLError: (ProgrammingError) value too long for type character varying... and silently truncate the inserted data? Thank you! David --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: SA ORM delete efficiency

2006-12-15 Thread ml
This is a duplicate mail (due to a recent SMTP problems). Don't reply. DS ml píše v Po 11. 12. 2006 v 23:13 +0100: Hi! I have a little questions about how does the SA work: Example: I borrowed a model from SA documentation example User/Address. My mapper is mapper(Address

[sqlalchemy] SA ORM delete efficiency

2006-12-14 Thread ml
Hi! I have a little questions about how does the SA work: Example: I borrowed a model from SA documentation example User/Address. My mapper is mapper(Address, addresses_table) mapper(User, users_table, properties = { 'addresses' : relation(Address, cascade=all, delete-orphan)

[sqlalchemy] Re: remote nondirect access to DB

2006-12-08 Thread ml
Client application doesn't mean web application and SqlAlchemy would be a too big hammer for SQL console (in my opinion). Well it will be an information system written with wxPython running on multiple computers. I don't want users to see information for direct access to the database. I was

[sqlalchemy] Re: remote nondirect access to DB

2006-12-08 Thread ml
Jonathan Ellis píše v Pá 08. 12. 2006 v 11:05 -0700: On 12/7/06, ml [EMAIL PROTECTED] wrote: I want to have a client application accessing a remote Postgres database but I don't want to distribute the user/password to the DB. I want clients to authenticate against some other table

[sqlalchemy] Re: remote nondirect access to DB

2006-12-08 Thread ml
Jonathan Ellis píše v Pá 08. 12. 2006 v 15:40 -0700: On 12/8/06, ml [EMAIL PROTECTED] wrote: Jonathan Ellis píše v Pá 08. 12. 2006 v 11:05 -0700: On 12/7/06, ml [EMAIL PROTECTED] wrote: I want to have a client application accessing a remote Postgres database but I don't want