Re: [sqlalchemy] Querying using objects

2013-04-18 Thread Richard Gerd Kuesters
Thanks Mike! I just did that :) And is a pretty, simple and reusable comparator for me. Cheers, Richard. On 04/17/2013 04:56 PM, Michael Bayer wrote: OK, if you want to stick with hybrids, you can define your own SomeClass.myattribute == someobject behavior by creating your own comparator,

[sqlalchemy] Calling Stored Procedure in MySQL with output parameter

2013-04-18 Thread Stephen Ray
My environment is Python 3.2, SQLAlchemy 0.8, MySQL 5.5, and using MySQL-connector 1.0.9. I have a stored procedure that takes two input parameters (both integers) and returns a single integer output parameter indicating the success of failure of the stored procedure. No record sets are

Re: [sqlalchemy] Calling Stored Procedure in MySQL with output parameter

2013-04-18 Thread Michael Bayer
to my knowledge, the existing DBAPIs for MySQL don't support output parameters (news to me that MySQL SPs did).But I haven't confirmed that. You'd need to figure out first how to do this with the plain DBAPI cursor, such as that of MySQL-python. Within SQLAlchemy for now you'd probably

Re: [sqlalchemy] Logger

2013-04-18 Thread Richard Gerd Kuesters
Thanks again Mike. I was hoping in a way to log only statements, as my app already uses Twisted logging facilites. I am trying to get rid of indexing bottlenecks . Cheers, Richard. On 04/17/2013 05:04 PM, Michael Bayer wrote: the easiest way is to use Python logging directly, where you can

Re: [sqlalchemy] Logger

2013-04-18 Thread Michael Bayer
the sqlalchemy.engine logger is only statements and their parameters. the example I gave routes just that one logger to a specific file. On Apr 18, 2013, at 9:30 AM, Richard Gerd Kuesters rich...@humantech.com.br wrote: Thanks again Mike. I was hoping in a way to log only statements, as my

Re: [sqlalchemy] Logger

2013-04-18 Thread Richard Gerd Kuesters
Strange. That's not the result I got here. Even my horrible debugging prints (from other modules) ended up there ... On 04/18/2013 10:39 AM, Michael Bayer wrote: the sqlalchemy.engine logger is only statements and their parameters. the example I gave routes just that one logger to a

Re: [sqlalchemy] Calling Stored Procedure in MySQL with output parameter

2013-04-18 Thread Stephen Ray
Michael, Thanks for the quick reply. As a workaround I wrapped the stored procedure in another stored procedure that selects the return status. Now I am getting an 'Unread results exception' when I execute. Here is the code fragment (where self._engine is a SQLAlchemy engine): t =

[sqlalchemy] How to insert ROW%ROWTYPE?

2013-04-18 Thread Wolfgang Meiners
Hi, i use sqlalchemy to create a postgresql database. Within this database i need a trigger. I found a recipe to declare triggers using DDL: (this is declared inside class Absence) trigger_ddl = DDL( CREATE OR REPLACE FUNCTION validate_absence() RETURNS trigger AS

[sqlalchemy] Re: How to insert ROW%ROWTYPE?

2013-04-18 Thread Wolfgang Meiners
Ok, i got it! It is as simple as that: replace tt timetable%ROWTYPE --- === new line inserted with tt timetable%%ROWTYPE; --- === new line inserted Wolfgang -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

Re: [sqlalchemy] How to insert ROW%ROWTYPE?

2013-04-18 Thread Mauricio de Abreu Antunes
Nice Job! Do you know The True reason since % is not a escape character? Em quinta-feira, 18 de abril de 2013, Wolfgang Meiners escreveu: Ok, i got it! It is as simple as that: replace tt timetable%ROWTYPE --- === new line inserted with tt

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

2013-04-18 Thread Ladislav Lenart
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 = session.query(cls).filter(exists(q0.with_entities('1').statement)) q = q.options(

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

2013-04-18 Thread Ladislav Lenart
Hello. I have found a solution to my problem: correlate(). The following code produces SQL I want (see below): q0 = session.query(Deal).join(ImportedPartnerShare).filter( Deal.main_deal_ext_id == cls.main_deal_ext_id, ImportedPartnerShare.partner_id == partner.id,

Re: [sqlalchemy] Calling Stored Procedure in MySQL with output parameter

2013-04-18 Thread Michael Bayer
yeah I've no idea, would need to get it working with raw cursor first to even know how this should be treated. On Apr 18, 2013, at 10:43 AM, Stephen Ray stephenr092...@gmail.com wrote: Michael, Thanks for the quick reply. As a workaround I wrapped the stored procedure in another

Re: [sqlalchemy] Calling Stored Procedure in MySQL with output parameter

2013-04-18 Thread Stephen Ray
Michael, As you suggested, I grabbed the underlying dbapi connection from the the sqlalchemy connection and was able to get the result back in a somewhat round about way (in the code that follows conn is a SQLAlchemy connection): mysqlconn = conn.connection cursor = mysqlconn.cursor()

[sqlalchemy] Re: How to insert ROW%ROWTYPE?

2013-04-18 Thread Wolfgang Meiners
Am 18.04.13 17:29, schrieb Mauricio de Abreu Antunes: Nice Job! Do you know The True reason since % is not a escape character? Thank you. I am not sure. I am not deep enough in python to answer this question, but i think it is relatet to Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012,

Re: [sqlalchemy] Re: How to insert ROW%ROWTYPE?

2013-04-18 Thread Richard Gerd Kuesters
That's probably the problem, thou %R is not known (as of Python 2.7.x, which I use). http://docs.python.org/2/library/stdtypes.html#string-formatting-operations http://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting Cheers, Richard. On 04/18/2013 03:09 PM, Wolfgang

[sqlalchemy] creating transaction

2013-04-18 Thread Philipp Kraus
Hello, I try to use SQLAlchemy in buildscripts for SCons, so I run my SCons script and depend on the data all tables are created. I'm new with SQLAlchemy and Python database access, so can I create a transaction with SQLAlchemy for the create table statements and also the insert statements, so

Re: [sqlalchemy] creating transaction

2013-04-18 Thread Richard Gerd Kuesters
Hello Phillip :) IMHO, your best options are the SA examples (in the source code) folder and, for further abstractions, you could check SA test units :) Works great for me! Cheers, Richard. Em 2013-04-18 17:22, Philipp Kraus escreveu: Hello, I try to use SQLAlchemy in buildscripts

[sqlalchemy] Out Params no longer working?

2013-04-18 Thread John Anderson
Hey, we have a lot of stored procedures that use out params like: CREATE PROCEDURE create_stuff @value INT, @id INT OUTPUT AS BEGIN INSERT into stuff ... SET @id = @@Identity END and when we rows = DBSession.execute() we reference these outparams via row['@id'] and this is fine in

Re: [sqlalchemy] Out Params no longer working?

2013-04-18 Thread Michael Bayer
can you be more specific by returns a tuple - the rows returned by ResultProxy are always RowProxy objects which are always addressable by string names. the names here might not be matching up, but that's a different issue. On Apr 18, 2013, at 5:52 PM, John Anderson son...@gmail.com wrote:

Re: [sqlalchemy] creating transaction

2013-04-18 Thread Philipp Kraus
Hi Gerd, I have taken a look to the examples, but I don't understand, in which way I can use the transaction with the create_all option. A short code excerpt: engine = sqlalchemy.create_engine(env[connection], echo = env.get(DATABASE_VERBOSE, False) ) metadata=

Re: [sqlalchemy] creating transaction

2013-04-18 Thread Richard Gerd Kuesters
Hey Phillip! First, you must understand a simple concept: when you declare a table in SA, either declarative or traditionally, you're already sayin' to the SA engine that there are tables. Then, you can create them (if they do not exist), populate them and drop'em. You can even specify your

Re: [sqlalchemy] creating transaction

2013-04-18 Thread Richard Gerd Kuesters
And ... Sorry for my bad english. Em 2013-04-18 20:23, Richard Gerd Kuesters escreveu: Hey Phillip! First, you must understand a simple concept: when you declare a table in SA, either declarative or traditionally, you're already sayin' to the SA engine that there are tables. Then, you

[sqlalchemy] sqlalchemy and firebird; quotes around table/column names

2013-04-18 Thread Holger Schramm
Hi, i am playing around with sqlalchemy.orm and firebird server. engine = create_engine('firebird+kinterbasdb://SYSDBA:masterkey@localhost/C:/path/to/database/DEMODATABASE.FDB') db = engine.connect() Session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine)) session

Re: [sqlalchemy] sqlalchemy and firebird; quotes around table/column names

2013-04-18 Thread Michael Bayer
specify __tablename__ as an all lower case name, which indicates that it's case insensitive. It will not be quoted, provided it consists of regular alphanumeric characters. Right now it is assumed to be case sensitive which results in quotes, and results in a non-match since that's probably

Re: [sqlalchemy] creating transaction

2013-04-18 Thread Michael Bayer
On Apr 18, 2013, at 4:22 PM, Philipp Kraus philipp.kr...@flashpixx.de wrote: Hello, I try to use SQLAlchemy in buildscripts for SCons, so I run my SCons script and depend on the data all tables are created. I'm new with SQLAlchemy and Python database access, so can I create a