[sqlalchemy] Enclose each test in a transaction

2013-06-07 Thread Victor Varvariuc
Hi! I am trying to make a base class for our tests, that after each test case all the changes made by tests and the tested code are rolled back. I saw the pattern here http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#joining-a-session-into-an-external-transaction, but i have some

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,

[sqlalchemy] [ANN] Modified WindowedRangeQuery recipe

2013-06-07 Thread Ladislav Lenart
Hello. I modified the recipe at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/WindowedRangeQuery to better suit my needs. Perhaps someone else will find this useful: CODE BEGIN from sqlalchemy.orm import subqueryload from

[sqlalchemy] Simple [?] question about column prefixes

2013-06-07 Thread Richard Gerd Kuesters
Hi all! I'm refactoring a database schema but I need it to mantain reverse compatibility with older versions of our software - using views. But, to avoid confusion to other developers, new tables have two underscores as a prefix, like: class Base(object): @declared_attr def

Re: [sqlalchemy] [BUG][PATCH] Function names not quoted when necessary

2013-06-07 Thread Michael Bayer
logged this as http://www.sqlalchemy.org/trac/attachment/ticket/2749 On Jun 6, 2013, at 10:27 PM, Ryan Kelly rpkell...@gmail.com wrote: Function names in SQL can contain pretty much anything, e.g.: =# create function A Bug?(integer) returns integer as $$ select $1; $$ language sql;

Re: [sqlalchemy] Enclose each test in a transaction

2013-06-07 Thread Michael Bayer
On Jun 7, 2013, at 3:29 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: 1. The tests code uses apilib.Session, while the tests use self.session. well depends on what you're testing, if the tests go out to logic which refers to the global apilib.Session, that's fine 2. Looks like

Re: [sqlalchemy] Simple [?] question about column prefixes

2013-06-07 Thread Michael Bayer
On Jun 7, 2013, at 9:31 AM, Richard Gerd Kuesters rich...@humantech.com.br wrote: Hi all! I'm refactoring a database schema but I need it to mantain reverse compatibility with older versions of our software - using views. But, to avoid confusion to other developers, new tables have two

Re: [sqlalchemy] Query and compiled_cache

2013-06-07 Thread Claudio Freire
On Thu, Jun 6, 2013 at 2:20 PM, Michael Bayer mike...@zzzcomputing.com wrote: diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index c2ec72c..b458975 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -40,12 +40,15 @@ from ..sql import (

Re: [sqlalchemy] Query and compiled_cache

2013-06-07 Thread Claudio Freire
On Fri, Jun 7, 2013 at 1:56 PM, Claudio Freire klaussfre...@gmail.com wrote: This is my current BakedQuery: class BakedQuery(sqlalchemy.orm.query.Query): F**k gmail again. Why the F+!k doesn't it show me that it'll bork all whitespace before I hit send... I smell a bug report coming...

Re: [sqlalchemy] Simple [?] question about column prefixes

2013-06-07 Thread Richard Gerd Kuesters
Thank you Mike! That brings me to another question: Let's say I have created a simple table (well, I have): class Language(Base): language_id = Column(Integer, Sequence('language_id_seq', optional=True), primary_key=True) language = Column(String(5), unique=True, default='undef')

[sqlalchemy] [ANN] Modified WindowedRangeQuery recipe

2013-06-07 Thread Ladislav Lenart
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/trac/wiki/UsageRecipes/WindowedRangeQuery to better suit my needs. Perhaps someone else will

Re: [sqlalchemy] Simple [?] question about column prefixes

2013-06-07 Thread Michael Bayer
OK, the prefix is on the mapped attribute name, not the column.So Language(_language = 'foo'). Guess you're looking for the opposite, huh. This gets more weird but this should work, the main difficulty is limiting the columns being altered to just those within a certain class

Re: [sqlalchemy] Simple [?] question about column prefixes

2013-06-07 Thread Richard Gerd Kuesters
Woah, I may have wondered that when I thought on attaching an event, but yes I was thinking the opposite when using it like the underscores in the table name level. I can't see how this was easier - lol - but it makes sense to me :) Thanks Mike! This should get into the SA examples or

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-07 Thread Charlie Clark
Am 07.06.2013, 00:05 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: can you show me the alternate design you have in mind? I'm not sure what normalize to favorites with strict 1:1 looks like. this is all just my own curiosity. the issue at hand is something different. Well, I

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-07 Thread Charlie Clark
Am 07.06.2013, 01:13 Uhr, schrieb Andy aml...@gmail.com: I may be misunderstanding the question, but the reason that having a favorite is optional is because I'm using mysql and mysql doesn't supported deferred constraints. Oh, I feel your pain! But you are using an engine that at leasts

[sqlalchemy] My mapped tables are missing insert, update methods

2013-06-07 Thread Michael Nachtigal
After reading the documentation, I am under the impression that my mapped tables should have the methods insert() and update(). For example, see here: http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html?highlight=update#sqlalchemy.schema.Table.update But my mapped tables don't have those

Re: [sqlalchemy] My mapped tables are missing insert, update methods

2013-06-07 Thread Josh Kuhn
Your User class is mapped to a Table. It's not the Table itself. To get the update method, you need to access User.__table__.update On Fri, Jun 7, 2013 at 4:12 PM, Michael Nachtigal michael.nachti...@catalinamarketing.com wrote: After reading the documentation, I am under the impression that

Re: [sqlalchemy] Connect to SQL Server (with pyodbc) getting error: sqlalchemy.exc.DBAPIError: (Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default dri

2013-06-07 Thread Victor Reichert
Thank you! That got me going. For what it's worth, I was using python 3.3 and trying to generate a custom connection string wtih the following command: import urllib string = urllib.quote_plus('DRIVER={SQL Server};Server=Server;Database=DB;Trusted_Connection=Yes') conn =

Re: [sqlalchemy] Connect to SQL Server (with pyodbc) getting error: sqlalchemy.exc.DBAPIError: (Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default dri

2013-06-07 Thread Michael Bayer
On Jun 7, 2013, at 6:11 PM, Victor Reichert vfr...@gmail.com wrote: Thank you! That got me going. For what it's worth, I was using python 3.3 and trying to generate a custom connection string wtih the following command: import urllib string = urllib.quote_plus('DRIVER={SQL

[sqlalchemy] AssociationProxy's behavior with == None seems unintuitive

2013-06-07 Thread Greg Yang
Right now a filter clause AssociationProxy == None Consider the following code: from sqlalchemy.engine import create_engine from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.orm import relationship from