Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-04 Thread Ladislav Lenart
Hello. I responded yesterday but it seems the mail did not make it. Here it goes and sorry for the duplicate... On 3.3.2016 21:09, Ladislav Lenart wrote: > Hello. > > > On 3.3.2016 19:52, Brian Cherinka wrote: >> Yeah, that might ultimately be the best way to go

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-03 Thread Ladislav Lenart
Hello. I think it would be (much) easier to simply rebuild the query from scratch before each run. IMHO the time to build the query is not that big a factor to justify the added source code complexity. HTH, Ladislav Lenart On 3.3.2016 05:47, Brian Cherinka wrote: > > > well

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Ladislav Lenart
On 10.9.2015 16:30, Mike Bayer wrote: > On 9/10/15 10:26 AM, Mike Bayer wrote: >> >> >> On 9/10/15 10:13 AM, Ladislav Lenart wrote: >>> Hello. >>> >>> Just a really, really tiny and pedantic correction... The stack >>> variable in the >

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Ladislav Lenart
the stack. HTH, Ladislav Lenart On 10.9.2015 15:48, Mike Bayer wrote: > > > On 9/10/15 9:35 AM, Mike Bayer wrote: >> >> >> On 9/10/15 8:48 AM, Pavel S wrote: >>> Let's say, I have declarative classes A, B, C, D. >>> >>> A is the parent >

Re: [sqlalchemy] mapper_configured event, class fully configured?

2015-08-28 Thread Ladislav Lenart
quite prefer that as I think it makes my code much more readable to have the relationship properties declared where they will exist. +100 I came to the same conclusion a long time ago and have never looked back :-) Just my 2c, Ladislav Lenart Cheers, Douglas On Monday, 24 August 2015

Re: [sqlalchemy] how to auto set foreignkey column?

2015-08-11 Thread Ladislav Lenart
in the second example. I personally prefer back_populates because each ORM definition is then complete on its own (i.e. both User and Address will each define the appropriate relationship connected to the other with back_populates kw). HTH, Ladislav Lenart On 11.8.2015 09:59, Sean Lin wrote

Re: [sqlalchemy] how fast can pure sqlalchemy perform?

2015-08-07 Thread Ladislav Lenart
SQLAlchemy is an excellent library to work with! For some numbers, see: http://docs.sqlalchemy.org/en/latest/faq/performance.html http://docs.sqlalchemy.org/en/latest/orm/examples.html#examples-performance HTH, Ladislav Lenart On 7.8.2015 11:16, kk wrote: Dear all, I am planning to totally

Re: [sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread Ladislav Lenart
can simulate RIGHT OUTER JOIN with LEFT JOIN if you change the order of the tables in the query. HTH, Ladislav Lenart J. On Monday, August 3, 2015 at 5:08:44 PM UTC+2, Ladislav Lenart wrote: Hello. pgAdmin query uses LEFT JOIN whereas SQLAlchemy query uses (inner) JOIN

Re: [sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread Ladislav Lenart
Hello. pgAdmin query uses LEFT JOIN whereas SQLAlchemy query uses (inner) JOIN. Replace .join(...) with .outerjoin(...) in your SQLAlchemy query. HTH, Ladislav Lenart On 3.8.2015 16:48, jurie.horne...@gmail.com wrote: I am using Python 2.7, SQLAlchemy 0.9.3, and PostgreSQL 9.4

Re: [sqlalchemy] Bizzarre insert behavior: NULL constraint violation with non-null value, column changes every run.

2015-07-29 Thread Ladislav Lenart
Hello. I don't know why but the problematic version uses bytes as keys in the params dictionary (e.g. b'batch_id') whereas the working version uses strings (e.g. 'batch_id'). I am not a Python 3 expert but I think that the two types are distinct and thus the search for a string fails. This would

Re: [sqlalchemy] Unlogged Postgresql Table

2014-12-17 Thread Ladislav Lenart
TEMPORARY with UNLOGGED. HTH, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send

[sqlalchemy] [Bug?][v0.9.8][postgres] Table.create(): checkfirst=True does NOT work for temporary tables

2014-12-04 Thread Ladislav Lenart
. Is there a fix/workaround for this? Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com

Re: [sqlalchemy] [Bug?][v0.9.8][postgres] Table.create(): checkfirst=True does NOT work for temporary tables

2014-12-04 Thread Ladislav Lenart
to drop the temp table. However it is nice to know that it will work correctly in all circumstances. Please, keep up the excellent work, because SQLAlchemy is probably the best library I have ever worked with! :-) Thank you, Ladislav Lenart On 4.12.2014 18:03, Michael Bayer wrote: On Dec 4, 2014

[sqlalchemy] [Q][postgres] Temporary table with ON COMMIT

2014-12-04 Thread Ladislav Lenart
was unable to figure this out on my own. Is this even possible? Fortunately for me, I don't need this feature (yet), the default is good enough for my purposes. Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group

[sqlalchemy] [Q] Relative speed of different querying methods

2014-11-12 Thread Ladislav Lenart
a rather complex query with several join-s and # filter conditions. Specifically, the query HAS various # literal arguments (i.e. Foo.bar == bar). q = session.query(Foo.id).distinct().join(...).filter(...) r = session.execute(q.statement).fetchall() Thank you in advance, Ladislav Lenart -- You

Re: [sqlalchemy] [Q] Semantic difference in not equal operator

2014-11-03 Thread Ladislav Lenart
references when the ultimate goal is to create a SQL SELECT. Thank you once again to both of you, Ladislav Lenart PS: Sorry for the delay. I was offline during the weekend. On 31 Oct 2014, at 16:36, Ladislav Lenart lenart...@volny.cz wrote: Hello. I have just noticed (by accident

[sqlalchemy] [Q] Semantic difference in not equal operator

2014-10-31 Thread Ladislav Lenart
Is this difference intentional? May I know why (i.e. the motivation)? Thanks in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr

Re: [sqlalchemy] how to tell if a relationship was loaded or not ?

2014-06-12 Thread Ladislav Lenart
Hello. Out of curiosity. Do you want this during (unit) testing or in the application logic itself? Ladislav Lenart On 11.6.2014 20:17, Jonathan Vanasco wrote: I can't find this in the API or by using `inspect` on an object. I'm trying to find out how to tell if a particular relationship

Re: [sqlalchemy] [Q] How to fix a circular dependency error?

2014-05-28 Thread Ladislav Lenart
attribute? OR the error is triggered simply by the fact that a cycle exists no matter whether the particular relationship is being updated or not? Thank you in advance, Ladislav Lenart On May 27, 2014, at 5:48 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. A specific DML request crashed

[sqlalchemy] [Q] How to fix a circular dependency error?

2014-05-27 Thread Ladislav Lenart
= set([...]) # about a text page of data but I do not understand them. If it matters, I am still using SA v0.7. If you need more info, just ask. Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group

Re: [sqlalchemy] a [probably] stupid query question

2014-03-20 Thread Ladislav Lenart
# for eachA, eachB in q... should produce what you want: SELECT A.*, B.* FROM A, B WHERE A.b_id = B.id HTH, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send

Re: [sqlalchemy] [SA0.7] Possible feature request for subqueryload?

2013-09-26 Thread Ladislav Lenart
Hello. On 25.9.2013 17:15, Michael Bayer wrote: On Sep 25, 2013, at 10:11 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. Would it be possible to make these two forms session.query(cls).options( subqueryload(cls.foos), subqueryload(cls.foos, Foo.bar

Re: [sqlalchemy] [SA0.7] Possible feature request for subqueryload?

2013-09-26 Thread Ladislav Lenart
. personal AND CORPORATE) * The rest only work with the personal. Thank you very much! It has been enlightening as always, Ladislav Lenart On 26.9.2013 16:13, Michael Bayer wrote: On Sep 26, 2013, at 9:30 AM, Ladislav Lenart lenart...@volny.cz wrote: Your thoughts on this? Do you see

[sqlalchemy] [SA0.7] Possible feature request for subqueryload?

2013-09-25 Thread Ladislav Lenart
: options.extend([ subqueryload(*prefix + [alias.contacts, Contact.phones]), subqueryload(*prefix + [alias.contacts, Contact.emails]), ]) return options Thank you, Ladislav Lenart -- You received this message because you are subscribed

Re: [sqlalchemy] Unit testing, mocking and dependency injection with SA Declarative.

2013-09-11 Thread Ladislav Lenart
However, be aware of differences between PostgreSQL and sqlite. For example sqlite does not support recursive CTEs. But I am sure there's more. Ladislav Lenart On 10.9.2013 18:43, Toph Burns wrote: Could you use an in-memory, sqlite db for your testing? For our applications, we have

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-03 Thread Ladislav Lenart
that these are shared among web requests and db sessions. Ladislav Lenart I haven't used Tornado before and don't know much about it. Its main feature is that it uses asynchronous IO, unlike most other python web servers that use threads for request handling. How do you make sure that a single request

Re: [sqlalchemy] How to make a SQLAlchemy query using exists with a correlated subquery containing joins?

2013-08-08 Thread Ladislav Lenart
into a composite UNIQUE constraint to preserve the integrity check. HTH, Ladislav Lenart On 8.8.2013 09:25, Etienne Rouxel wrote: I have managed to add the missing SQL part with the following query: e = session.query(Plant).\ join(Article, Plant.articles).\ join(Catalogitem

Re: [sqlalchemy] Rolling back all changes between unit tests

2013-07-24 Thread Ladislav Lenart
to assert something against the database. * Use rollback() at the end of a unit test. HTH, Ladislav Lenart On 23.7.2013 18:58, Ib Lundgren wrote: Hey all, I'd like to have a clean DB between tests, one approach that works is to drop tables and recreate fixtures. This can be quite slow and I'd

Re: [sqlalchemy] flask-sqlalchemy pysybase connections

2013-06-17 Thread Ladislav Lenart
() and web_session.release_lock(). HTH, Ladislav Lenart On 16.6.2013 19:10, Michael Bayer wrote: On Jun 16, 2013, at 12:55 PM, Kevin S kevinrst...@gmail.com mailto:kevinrst...@gmail.com wrote: I can try to get another dbapi installed later this week and see if that works. However, I had to jump through some

Re: [sqlalchemy] [ANN] Modified WindowedRangeQuery recipe

2013-06-17 Thread Ladislav Lenart
will find it useful too. Ladislav Lenart On 7.6.2013 20:03, Ladislav Lenart wrote: Hello. Resending because the original e-mail does not seem to make it to the mailing list. Apologise for any duplicates. Here we go... Hello. I modified the recipe at http://www.sqlalchemy.org

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-17 Thread Ladislav Lenart
Hello. Here is the fully self-contained regression of the issue, including the workaround for SA 0.7.9. Thank you again, because I wouldn't figure it out without your help (the select_from part). I haven't tried it on SA 0.9. If you have any questions, please ask. HTH, Ladislav Lenart

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-17 Thread Ladislav Lenart
it took me quite a while to get right, especially the aliasing between tables and classes. Also, I wouldn't figure it out without your help (I mean the part with select_from). Thank you again, Ladislav Lenart On 13.6.2013 18:44, Michael Bayer wrote: On Jun 13, 2013, at 11:03 AM, Ladislav Lenart

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-17 Thread Ladislav Lenart
it took me quite a while to get right, especially the aliasing between tables and classes. Also, I wouldn't figure it out without your help (I mean the part with select_from). Thank you again, Ladislav Lenart On 13.6.2013 18:44, Michael Bayer wrote: On Jun 13, 2013, at 11:03 AM, Ladislav Lenart

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-14 Thread Ladislav Lenart
Hello. On 13.6.2013 18:44, Michael Bayer wrote: On Jun 13, 2013, at 11:03 AM, Ladislav Lenart lenart...@volny.cz wrote: Unfortunately migrating to SA 0.9 is not an option for me at the moment due to severe time constraints. I was pretty sure you'd say that, though I'm really looking

[sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-13 Thread Ladislav Lenart
stuck so any help is much appreciated. Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-13 Thread Ladislav Lenart
whatever it pleases as long as it returns Foo instances with properly populated relations. Please help me write it (or tell me that it is not possible in SA 0.7.9, though I highly doubt that). Thank you, Ladislav Lenart On 13.6.2013 15:51, Michael Bayer wrote: Please try out 0.9 from the git

Re: [sqlalchemy] SA0.7.9 - poor query performance (full scan instead of index scan because of joined table inheritance)

2013-06-13 Thread Ladislav Lenart
Hello. Just a minor correction: The new query can return whatever it pleases as long as it *also* returns Foo instances with properly populated relations. The rest of the e-mail is the same. Please help me, Ladislav Lenart On 13.6.2013 17:03, Ladislav Lenart wrote: Unfortunately

Re: [sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-12 Thread Ladislav Lenart
Correction. It was cherrypy's fault. It uses 'implicit' locking of web sessions by default ('tools.sessions.locking'). We changed it to 'explicit' and call web_session.acquire_lock() / web_session.release_lock() manually when we need to. This works like a charm! HTH, Ladislav Lenart

Re: [sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-11 Thread Ladislav Lenart
Hello. On 10.6.2013 18:41, Michael Bayer wrote: On Jun 10, 2013, at 11:46 AM, Ladislav Lenart lenart...@volny.cz wrote: I have no idea what is wrong. Please help me diagnose this! Note that OS monitor shows several cherrypy threads, each gets its share, so the cherrypy setup seems

Re: [sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-11 Thread Ladislav Lenart
and sorry for the noise, Ladislav Lenart On 11.6.2013 09:08, Ladislav Lenart wrote: Hello. On 10.6.2013 18:41, Michael Bayer wrote: On Jun 10, 2013, at 11:46 AM, Ladislav Lenart lenart...@volny.cz wrote: I have no idea what is wrong. Please help me diagnose this! Note that OS monitor

[sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-10 Thread Ladislav Lenart
, each gets its share, so the cherrypy setup seems to be OK. Thank you in advance, Ladislav Lenart # Snippet of db.py # def init(conn_string, echo=False, base=None, pool_size=5): engine = create_engine(conn_string, echo=echo, pool_size=pool_size

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-07 Thread Ladislav Lenart
On 6.6.2013 19:33, Michael Bayer wrote: On Jun 6, 2013, at 12:56 PM, Ladislav Lenart lenart...@volny.cz wrote: Hello. I have already solved the issue by using subquery: SELECT t.id AS t_id, t.rownum AS t_rownum FROM ( SELECT FROM foo.id AS id, row_number

[sqlalchemy] [ANN] Modified WindowedRangeQuery recipe

2013-06-07 Thread Ladislav Lenart
as fast as the same query without yield_per(). But this will be highly dependent on the query I guess. WARNING: We do not use this in the production yet. Use at your own risk. Happy SA hacking, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] [ANN] Modified WindowedRangeQuery recipe

2013-06-07 Thread Ladislav Lenart
own risk. Happy SA hacking, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send

[sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Ladislav Lenart
of lost here, because something very similar should work according to the original recipe. Note that I apply with_entities() on the original query whereas the recipe uses from_self() on the column. Do you have any idea what should I do to fix this? Thank you in advance, Ladislav Lenart -- You

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Ladislav Lenart
, Ladislav Lenart On 6.6.2013 18:26, Charlie Clark wrote: Am 06.06.2013, 16:30 Uhr, schrieb Ladislav Lenart lenart...@volny.cz: The returned query q produces the following SQL: SELECT foo.id AS foo_id, row_number() OVER (ORDER BY foo.id) AS rownum FROM foo WHERE rownum

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-05 Thread Ladislav Lenart
() / order_by()) to obtain the objects I want. I use this query to calculate window intervals. I don't have to use it again to fetch the objects, because I already have their id intervals. Am I right? Thank you, Ladislav Lenart On 4.6.2013 19:15, Ladislav Lenart wrote: On 4.6.2013 18:49, Michael

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-05 Thread Ladislav Lenart
Contact 5 123456789 987654321 555777999 Contact 4 123456789 987654321 555777999 Contact 3 123456789 987654321 555777999 Contact 2 123456789 987654321 555777999 Contact 1 123456789 987654321 555777999 Thank you, Ladislav Lenart On 5.6.2013 11:26, Ladislav Lenart wrote: Hello. I have one more

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-05 Thread Ladislav Lenart
that it works just fine with yield_per(). Can you elaborate on that one please? Thank you, Ladislav Lenart On 5.6.2013 14:03, Ladislav Lenart wrote: Hello. I've tried an experiment to verify that yield_per() with subqueryload() behaves as badly as you described, but according to my practical

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-05 Thread Ladislav Lenart
Ok, so yield_per() is useless when subqueryload() is used. Thank you, Ladislav Lenart On 5.6.2013 16:27, Michael Bayer wrote: the Query emitted by subqueryload does not use yield_per. so if your total result set is 1000 rows, and the total rows represented by all the collections is 1

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
, and the number of bars total is 1, you will load 1 additional rows for *each* yield per of 50. Ok, I think I get it. Is there a way to make it all work without the performance penalty of subqueryload? For example, what will happen if I replace it with joinedload(cls.bars)? Ladislav Lenart

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
. Something like 10-5 rows from a table with 1-2 million rows. The windowed query iterates over many completely empty windows. Can I modify the recipe so it preserves the filtering and creates windows only for the interesting subset of the table? Thank you, Ladislav Lenart On 4.6.2013 17:18

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
WindowedRangeQuery recipe. * I know I can use with_entities() for this. * I will use q2 to obtain the window ranges. * I will iterate over the window ranges and apply each to the original q and execute it in a loop. Can this strategy work? Thank you, Ladislav Lenart On 4.6.2013 17:57

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
On 4.6.2013 18:49, Michael Bayer wrote: On Jun 4, 2013, at 12:28 PM, Ladislav Lenart lenart...@volny.cz wrote: Absolutely, you should do whatever you have to in order to get the range you want, in fact the recipe even says this... Ok. What I want to do is basically the following

Re: [sqlalchemy] nested inheritance / polymorphic relationships

2013-06-04 Thread Ladislav Lenart
with inheritance of others on this list, but mine in SA0.7.9 is not that good. I encountered various limitations along the way. I guess it dependes on the complexity of the queries. We plan to get rid of it eventually in our app. However, if I am not mistaken, SA0.8 addresses all the quirks. Ladislav Lenart

Re: [sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-31 Thread Ladislav Lenart
these three constructs OR A 'highlevel user-friendly step-by-step description' about what each construct does, so that I can see where they differ. Anyway, keep the excellent work! Ladislav Lenart On 31.5.2013 01:12, Michael Bayer wrote: this is very helpful because you are here running

Re: [sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-31 Thread Ladislav Lenart
the supplied regression. Ladislav Lenart On 31.5.2013 12:06, Andrija Zarić wrote: On Friday, May 31, 2013 11:46:46 AM UTC+2, Ladislav Lenart wrote: Glad I could help, but I don't understand what is going on. Neither ticket description nor the patch itself helped me. Sorry. What

Re: [sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-31 Thread Ladislav Lenart
Thank you for the excellent description. The replace in bold did the trick for me :-) Ladislav Lenart On 31.5.2013 16:31, Michael Bayer wrote: On Friday, May 31, 2013 6:31:25 AM UTC-4, Ladislav Lenart wrote: Hello. I've read the patch and the new documentation and i've

[sqlalchemy] [Q][0.7.9] DetachedInstanceError

2013-05-30 Thread Ladislav Lenart
and in random places? * I am unable to reproduce it at will? The web app is running cherrypy under apache. Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails

Re: [sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-30 Thread Ladislav Lenart
, partner.sponsor_id AS partner_sponsor_id FROM q_cte JOIN partner ON q_cte.partner_id = partner.id The bug is somehow related to the use of select_from(). Hope this helps, Ladislav Lenart On 10.5.2013 22:04, Michael Bayer wrote: On May 10, 2013, at 3:03 PM, Ladislav Lenart lenart

[sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-10 Thread Ladislav Lenart
: q = session.query(cls) q = q.join(q_cte_union, cls.id == q_cte_union.c.partner_id) return q Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop

Re: [sqlalchemy] [Q][0.7.9] How to issue apply_labels() on an ORM query?

2013-05-10 Thread Ladislav Lenart
? Thank you, Ladislav Lenart On 10.5.2013 17:17, Michael Bayer wrote: The Query usually does apply_labels automatically. if you are getting that warning with your query below, there's too much going on there for me to identify by sight where that might be happening, I would need actual code

[sqlalchemy] [Q] WindowedRangeQuery recipe

2013-04-26 Thread Ladislav Lenart
reclaimed? I know the session keeps them in an identity map. Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr

Re: [sqlalchemy] [Q] WindowedRangeQuery recipe

2013-04-26 Thread Ladislav Lenart
Hello. I think I understand it all now. Thank you, Ladislav Lenart On 26.4.2013 13:22, Gunnlaugur Thor Briem wrote: No, the comma is supposed to be there; it's for tuple unpacking. The iterable q yields tuples (which in this case are of length one, because the resultset has only one

[sqlalchemy] [Q][SA 07.9] - Trouble with EXISTS that references main SELECT

2013-04-18 Thread Ladislav Lenart
) How can I do that? Thank you, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send

Re: [sqlalchemy] [Q][SA 07.9] - Trouble with EXISTS that references main SELECT

2013-04-18 Thread Ladislav Lenart
), ) Ladislav Lenart On 18.4.2013 18:54, Ladislav Lenart wrote: Hello. The following SA code: # cls = Advice q0 = session.query(Deal).join(ImportedPartnerShare).filter( Deal.main_deal_ext_id == cls.main_deal_ext_id, ImportedPartnerShare.partner_id == partner.id, ) q

Re: [sqlalchemy] Aggregating results of a union

2013-03-21 Thread Ladislav Lenart
attached a complete python script that you can run to verify if it's correct. HTH, Ladislav Lenart On 21.3.2013 09:07, Alexey Vihorev wrote: Hi! I have this query: q1 =(s.query() .add_columns( Movement.customer_id

Re: [sqlalchemy] Aggregating results of a union

2013-03-21 Thread Ladislav Lenart
As usual, I forgot to add the attachment... Ladislav Lenart On 21.3.2013 13:57, Ladislav Lenart wrote: Hello. Perhaps something like this is what you are looking for? def q_union(): s = session q1 = s.query( Movement.customer_id.label('customer_id

Re: [sqlalchemy] Placeholder values

2013-03-20 Thread Ladislav Lenart
42' HTH, Ladislav Lenart On 20.3.2013 18:39, Alexey Vihorev wrote: Hi! I’ve got to unite two tables preserving some of their columns as distinct, so to comply with the “same number, same type” requirement of the UNION operator I use placeholder values, like this: *SELECT

Re: [sqlalchemy] [Q] SA 0.7.9 on postgres 9.1 - problem with COPY FROM command

2013-03-14 Thread Ladislav Lenart
haven't changed at all. We only added a couple of indexes. Might these cause such a catastrophic behaviour? Ladislav Lenart On 14.3.2013 12:04, Ladislav Lenart wrote: Hello. DISCLAIMER: This is NOT about SQL Alchemy per se. I just seek opinions and ideas from people that are familiar

[sqlalchemy] [Q] Struggle with exists

2013-03-01 Thread Ladislav Lenart
times but I still don't get it.) Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com

Re: [sqlalchemy] [Q] Struggle with exists

2013-03-01 Thread Ladislav Lenart
') replaces q's SELECT... part. exists(q1.with_entities('1').statement), exists(q2.with_entities('1').statement), ) ) One unrelated question: What is the difference between Query.add_column() and Query.add_entity()? Thank you again, Ladislav Lenart On 1.3.2013 18

Re: [sqlalchemy] [Q] SA 0.7.9 - missing from when using union_all and joinedload_all

2013-02-28 Thread Ladislav Lenart
that I am using SA 0.7.8 at the moment (version from debian distro). I apologize for the err subject. I did not check it when I wrote that line, I just assumed. Thank you again, Ladislav Lenart On 28.2.2013 04:12, Michael Bayer wrote: OK, I've reconstructed mappings which correspond directly

Re: [sqlalchemy] [Q] SA 0.7.10 - issues with union, with_polymorphic, joinedload / subqueryload

2013-02-28 Thread Ladislav Lenart
after the main query which renders the joinedload useless. subqueryload_all crashes. I would be glad for any words of advice or idea(s) for possible workaround(s), Ladislav Lenart On 28.2.2013 10:26, Ladislav Lenart wrote: Thank you very much for your valuable time, Michael! Your example

Re: [sqlalchemy] [Q] SA 0.7.10 - issues with union, with_polymorphic, joinedload / subqueryload

2013-02-28 Thread Ladislav Lenart
), ) This will also be my solution for the foreseeable future. Thank you, Ladislav Lenart On 28.2.2013 11:29, Ladislav Lenart wrote: Hello again. I have successfully installed SA 0.7.10 and the query as-is works. However jonedload_all / subqueryload_all options on the query do

Re: [sqlalchemy] [Q] SA 0.7.10 - issues with union, with_polymorphic, joinedload / subqueryload

2013-02-28 Thread Ladislav Lenart
this (much) sooner. I guess I was stuck on with_polymorphic() and haven't expected that PersonalClient would magically join on Client as well. Thank you, Ladislav Lenart On 28.2.2013 11:48, Ladislav Lenart wrote: Hello. I have new insigths / new bug to report. Even when I reformat

Re: [sqlalchemy] [Q] SA 0.7.10 - issues with union, with_polymorphic, joinedload / subqueryload

2013-02-28 Thread Ladislav Lenart
Cool! I will switch to it once it is officially released. Thank you, Ladislav Lenart On 28.2.2013 19:04, Michael Bayer wrote: All of that has been fixed in 0.8. With 0.8 both versions work fine. On Feb 28, 2013, at 5:29 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello again. I

[sqlalchemy] [Q] SA 0.7.9 - missing from when using union_all and joinedload_all

2013-02-27 Thread Ladislav Lenart
doing wrong? / How can I fix this? Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com

Re: [sqlalchemy] [Q] SA 0.7.9 - missing from when using union_all and joinedload_all

2013-02-27 Thread Ladislav Lenart
column in row for column 'client.id' I also tried it without with_polymorphic() and the result is the same. Do you have any idea what is going on / what am I doing wrong and how I can fix this? Thanks, Ladislav Lenart On 27.2.2013 19:05, Michael Bayer wrote: On Feb 27, 2013, at 12:21 PM

Re: [sqlalchemy] [Q] Move elements in one-to-many relationship to a new owner

2012-11-13 Thread Ladislav Lenart
solved, at least for now. I will try to dig deeper when I have more time. Ladislav Lenart On 9.11.2012 23:22, Michael Bayer wrote: there's no mapping or code example provided here, which makes a condition like this extremely difficult to diagnose, however I've prepared a test script that takes

Re: [sqlalchemy] [Q] Move elements in one-to-many relationship to a new owner

2012-11-09 Thread Ladislav Lenart
such somewhere? All my attempts with session.flush() failed (had no effect). Thank you, Ladislav Lenart On 8.11.2012 17:30, Ladislav Lenart wrote: Hello. I have a client which has a collection of ClientProduct-s (ClientProduct has a FK to Client). The following code: # Move some client

Re: [sqlalchemy] [Q] Transform a select part of a query

2012-10-25 Thread Ladislav Lenart
Cool! That is what I was looking for. Thank you, Ladislav Lenart On 24.10.2012 20:00, Michael Bayer wrote: with_entities() will give you this: http://docs.sqlalchemy.org/en/rel_0_7/orm/query.html#sqlalchemy.orm.query.Query.with_entities On Oct 24, 2012, at 11:21 AM, Ladislav Lenart

Re: [sqlalchemy] Problem writing a query with distinct

2012-10-24 Thread Ladislav Lenart
as expected in combination with limit and offset. HTH, Ladislav Lenart On 24.10.2012 00:59, Jonathan Vanasco wrote: I'm trying to write a query against Postgres and it's driving me a bit mad. Hoping someone here can help. I'm make the example in something topical... voting! Given

[sqlalchemy] [Q] Transform a select part of a query

2012-10-24 Thread Ladislav Lenart
number_of_people_older_than(age) q = people_older_than(21) q_count = q# Apply some magic here. return q_count.scalar() Thank you in advance, Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

Re: [sqlalchemy] [Q] Transform a select part of a query

2012-10-24 Thread Ladislav Lenart
)) q = q.filter(Person.age age) return q (I am not sure if the order_by part can remain or not.) Is this possible somehow? I am pretty sure I read something along these lines but cannot find it anywhere. Ladislav Lenart On 24.10.2012 17:10, Simon King wrote: On Wed, Oct 24, 2012 at 3:59 PM

[sqlalchemy] [Q] SqlAlchemy via pyodbc to MSSQL from Linux

2012-10-10 Thread Ladislav Lenart
* To MSSQL * Via pyodbc * using freetds ? Are there some differences? Thank you, Ladislav Lenart -- 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

Re: [sqlalchemy] SOLVED [Q] SQLSoup and PYODBC from Linux

2012-10-10 Thread Ladislav Lenart
://username:password@zfp, convert_unicode=True, echo='debug' ) db = SqlSoup(engine) # Same as in step 10 db.execute(...) # OR x = db.some_table.filter(...).one() Enjoy! Ladislav Lenart -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

Re: [sqlalchemy] [Q] SqlAlchemy via pyodbc to MSSQL from Linux

2012-10-10 Thread Ladislav Lenart
Hello. Thank you for the information. I am using freetds 0.91 without issues. But note that on Debian/testing, the driver file libtdsodbc.so is NOT part of any freetds-* package. It is part of the package tdsodbc. See my previous e-mail for detailed installation instructions. Ladislav Lenart

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-09 Thread Ladislav Lenart
for your kind assistance. Ladislav Lenart On 8.10.2012 19:06, Michael Bayer wrote: if you didnt have this problem with pymssql then please apply the patch I sent previously. However, I'm going to bet the problem remains as it seems something is not right with how your database

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-09 Thread Ladislav Lenart
| | | +---+ SQL select prijmeni from osoba where id_osoba = 462493 prijmeni asov� SQLRowCount returns 1 1 rows fetched SQL Ladislav Lenart On 9.10.2012 12:03, Ladislav Lenart wrote: Hello. No, I was not able

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-09 Thread Ladislav Lenart
. Furthermore the correct value is 'osoba' (a table name). I guess the conversion stripped out the odd character. Current state of nvarchar processing in my dev env: tsql OK isql OK pyodbc KO Ladislav Lenart On 9.10.2012 16:19, Michael Bayer wrote: On Oct 9, 2012, at 6:03 AM, Ladislav Lenart

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
). Note the password contains the character '@'. The preceeding '\' is my attempt to escape it. What connection string should I use to connect to MSSQL via pyodbc using freetds? Thank you, Ladislav Lenart THE TRACEBACK: Traceback (most recent call last): File /home/lada/.eclipse

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
, line 412, in reflecttable raise exc.NoSuchTableError(table.name) sqlalchemy.exc.NoSuchTableError: mlm_spol Any ideas? Thanks, Ladislav Lenart On 8.10.2012 11:11, Ladislav Lenart wrote: Hello. otherwise, I'd consider using pyodbc for which the dialect and DBAPI are production quality

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
;TDS_VERSION=8.0;') engine = create_engine('mssql+pyodbc://', creator=connect) db = SqlSoup(engine) x = db.execute(select * from mlm_spol).fetchone() print x Any ideas what I have to do to make SqlSoup's ORM work? I am out of ideas. Ladislav Lenart On 8.10.2012 15:02, Ladislav Lenart wrote: Hello again

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
was established successfully and the problem lies elsewhere. Am I wrong? Ladislav Lenart On 8.10.2012 16:20, Michael Bayer wrote: no such table usually means you're not connected to the database that you think you are. I'd strongly suggest configuring an ODBC datasource within FreeTDS

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
supports_unicode_binds and convert_unicode but none of them worked. Ladislav Lenart CODE: import pyodbc from sqlalchemy.engine import create_engine from sqlalchemy.ext.sqlsoup import SqlSoup def connect(): return pyodbc.connect('DRIVER={FreeTDS};SERVER=10.230.128.140;PORT=1433;DATABASE=ZFP_CRM

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-08 Thread Ladislav Lenart
connect style. And the code that uses db.execute('select * from mlm_spol').fetchone() still works... Any other ideas? Ladislav Lenart On 8.10.2012 17:45, Michael Bayer wrote: your freetds datasource should be configured with CLIENT_CHARSET=utf8 as I illustrated earlier: [ms_2005] host

[sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-05 Thread Ladislav Lenart
? Thank you, Ladislav Lenart -- 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+unsubscr...@googlegroups.com. For more options

[sqlalchemy] [Q] Why the following emits SQL for slot access?

2012-09-27 Thread Ladislav Lenart
, return it. What am I doing wrong? Thank you, Ladislav Lenart -- 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+unsubscr

Re: [sqlalchemy] [Q] Why the following emits SQL for slot access?

2012-09-27 Thread Ladislav Lenart
not work? Thank you, Ladislav Lenart On 27.9.2012 20:06, Michael Bayer wrote: On Sep 27, 2012, at 1:55 PM, Ladislav Lenart wrote: Hello again. I have the following test query: def test_slot_access_after_query(self): q = self.session.query(Foo, Bar).with_labels() q

  1   2   >