Re: [sqlalchemy] overriding base constructor to allow non-column named keys in the constructor dict

2014-12-11 Thread Mariano Mara
, Mariano Mara wrote: 2014-12-11 13:35 GMT-03:00 dewey de...@pathoz.com: I'm importing lots of text files, using csv.dictReader I then create model instances and store the recs in the DB One row from the csv file might represent a child-row, plus 4-5 parents (using get_or_create

Re: [sqlalchemy] is there a way to customize the names of declarative_base or mixin columns at class creation time?

2014-12-11 Thread Mariano Mara
2014-12-11 17:28 GMT-03:00 dewey de...@pathoz.com: Oh doh...that is perfect!!! Except for now, I either need to merge my __mapper_args__ from each table to my base __mapper_args__ Or is there a way to add to __mapper_args__ in the base DYNAMICALLY based on some property in the class? That

[sqlalchemy] NVARCHAR doubt

2014-09-30 Thread Mariano Mara
Hi there. I have some code that works ok in PG and now I need to make it work with Oracle, however I am hitting this error with NVARCHAR and I am not sure how to handle it. First a small code in order you can reproduce it (as you can see name has been defined as UnicodeText): from sqlalchemy

[sqlalchemy] Re: NVARCHAR doubt

2014-09-30 Thread Mariano Mara
Sorry, I meant NCLOB, not NVARCHAR. 2014-09-30 16:57 GMT-03:00 Mariano Mara mariano.m...@gmail.com: Hi there. I have some code that works ok in PG and now I need to make it work with Oracle, however I am hitting this error with NVARCHAR and I am not sure how to handle it. First a small code

[sqlalchemy] Re: NVARCHAR doubt

2014-09-30 Thread Mariano Mara
:06 GMT-03:00 Mariano Mara mariano.m...@gmail.com: Sorry, I meant NCLOB, not NVARCHAR. 2014-09-30 16:57 GMT-03:00 Mariano Mara mariano.m...@gmail.com: Hi there. I have some code that works ok in PG and now I need to make it work with Oracle, however I am hitting this error with NVARCHAR and I

[sqlalchemy] Update instead of delete on collection

2014-07-15 Thread Mariano Mara
Hi all Each time my Parent class is edited and one of the elements from its Child relationship is removed I want to invalidate this element (e.g. element.valid=False) instead of actually performing the delete DML instruction. How can I achieve that? I have created a remove event listener and I

Re: [sqlalchemy] Update instead of delete on collection

2014-07-15 Thread Mariano Mara
2014-07-15 14:47 GMT-03:00 Michael Bayer mike...@zzzcomputing.com: On Jul 15, 2014, at 1:27 PM, Mariano Mara mariano.m...@gmail.com wrote: Hi all Each time my Parent class is edited and one of the elements from its Child relationship is removed I want to invalidate this element (e.g

[sqlalchemy] Relationship issue with composite foreign key

2014-02-19 Thread Mariano Mara
Hi everyone, I am hitting an error while defining a relationship with a parent table with a composite primary key (my child class has two attributes that point to the same parent class -with a composite pk- but both relationships are properly defined with the 'foreign_keys' parameter): I am

Re: [sqlalchemy] Relationship issue with composite foreign key

2014-02-19 Thread Mariano Mara
On 19/02/14 15:28, Michael Bayer wrote: On Feb 19, 2014, at 1:14 PM, Mariano Mara mariano.m...@gmail.com wrote: # relationships runner = relationship(User, foreign_keys=[uid, oid], #primaryjoin=and_(Bet.uid==User.uid, Bet.oid==User.oid

Re: [sqlalchemy] Relationship issue with composite foreign key

2014-02-19 Thread Mariano Mara
On 19/02/14 16:01, Michael Bayer wrote: On Feb 19, 2014, at 1:34 PM, Mariano Mara mariano.m...@gmail.com wrote: On 19/02/14 15:28, Michael Bayer wrote: On Feb 19, 2014, at 1:14 PM, Mariano Mara mariano.m...@gmail.com wrote: # relationships runner = relationship(User

[sqlalchemy] Expected behaviour for Oracle's lost contact

2013-12-05 Thread Mariano Mara
Hi there, in one application I am using sqlalchemy 0.7.8 against Oracle 11 release 1 and I am hitting Oracle's lost contact more times than I would like to. Since the app seems unable to recover from the error, I have to restart it completely (it is a pyramid app). According to this

Re: [sqlalchemy] Expected behaviour for Oracle's lost contact

2013-12-05 Thread Mariano Mara
. thanks so much for your quick answer. I will review this option and evaluate if I can use it. On Dec 5, 2013, at 11:05 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 5, 2013, at 10:54 AM, Mariano Mara mariano.m...@gmail.com wrote: Hi there, in one application I am using

Re: [sqlalchemy] postgres with queries

2013-09-16 Thread Mariano Mara
On 16/09/13 11:49, Chris Withers wrote: Hi All, I know I asked this before, but I can't find the answer... How would I get SQLALchemy to generate these: http://www.postgresql.org/docs/9.2/static/queries-with.html cheers, Chris look here:

Re: [sqlalchemy] Reliable way to read comments from database schema

2013-06-05 Thread Mariano Mara
On 06/04/2013 11:22 PM, Warwick Prince wrote: On 06/04/2013 10:46 PM, Michael Bayer wrote: There's a long standing ticket to add support for comments, at least at the DDL level. I don't think anyone has looked into what level of support we get from the various backends as far as

Re: [sqlalchemy] Reliable way to read comments from database schema

2013-06-04 Thread Mariano Mara
On 06/04/2013 10:46 PM, Michael Bayer wrote: There's a long standing ticket to add support for comments, at least at the DDL level. I don't think anyone has looked into what level of support we get from the various backends as far as reflection. So its something the library has room for,

Re: [sqlalchemy] distinct on

2013-05-23 Thread Mariano Mara
On 05/23/2013 04:42 AM, jo wrote: |Hi all, I wondered if it is possible to execute a partial distinct in sqlalchemy. The following query works in oracle and postgresql: select distinct col1, first_value(col2) over (partition by col1 order by col2 asc) from tmp; How can I do such query in

Re: [sqlalchemy] Creating an index if it doesn't exist

2013-05-23 Thread Mariano Mara
On 05/23/2013 09:06 PM, Mike Bissell wrote: How might I convince SQLAlchemy 0.7.9 to create a newly added index on a table in the event that the index doesn't already exist? This new index is created as a member of __table_args__; it is not instantiated with index=True. I have many such

Re: [sqlalchemy] Tricky situation

2013-04-29 Thread Mariano Mara
to do so, I will surely appreciate it. Mariano On 04/25/2013 11:08 AM, Mariano Mara wrote: On 04/25/2013 10:22 AM, Richard Gerd Kuesters wrote: Hi all, I've been playing with sqla_hierarchy from https://github.com/marplatense/sqla_hierarchy . That code of that sqla_hierarchy was written

Re: [sqlalchemy] Tricky situation

2013-04-25 Thread Mariano Mara
On 04/25/2013 10:22 AM, Richard Gerd Kuesters wrote: Hi all, I've been playing with sqla_hierarchy from https://github.com/marplatense/sqla_hierarchy . That code of that sqla_hierarchy was written to provide a limited support for cte, from the time when sqalchemy didn't have cte. Since

Re: [sqlalchemy] Modifying a relationship before it gets inserted

2012-01-16 Thread Mariano Mara
On 05.01.12 16:13, Michael Bayer wrote: On Jan 5, 2012, at 3:03 PM, Mariano Mara wrote: Hi there! I have a master-detail entity. Since I do some post-processing work on the details before inserting the entity in the db, I added an 'after_insert' event where I do the extra stuff

[sqlalchemy] Modifying a relationship before it gets inserted

2012-01-05 Thread Mariano Mara
Hi there! I have a master-detail entity. Since I do some post-processing work on the details before inserting the entity in the db, I added an 'after_insert' event where I do the extra stuff. One of the things I need is to make sure certain details have been selected by the user and in case he

[sqlalchemy] sqlalchemy is ignoring the CheckConstraint name parameter while creating a check constraint

2011-10-21 Thread Mariano Mara
Hi all, the subject pretty much explains it all. Here's a complete example of the issue. Any tips will be appreciate. Regards, Mariano Python 2.7.2 (default, Oct 14 2011, 23:34:02) [GCC 4.5.2] on linux2 Type help, copyright, credits or license for more information. import sqlalchemy

Re: [sqlalchemy] sqlalchemy is ignoring the CheckConstraint name parameter while creating a check constraint

2011-10-21 Thread Mariano Mara
On Oct 21, 2011, at 7:10 PM, Mariano Mara wrote: Hi all, the subject pretty much explains it all. Here's a complete example of the issue. Any tips will be appreciate. Regards, Mariano Python 2.7.2 (default, Oct 14 2011, 23:34:02) [GCC 4.5.2] on linux2 Type help, copyright

Re: [sqlalchemy] bulk selection

2011-08-12 Thread Mariano Mara
On 12.08.11 09:41, Eduardo wrote: Dear All, I have a list of elements for which I need to establish if they are in a tadabase. I can make for each element a separate query but I am afraid that that is not the best approach what is the best practice in this case? Thanks Depending on the

[sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
Hi. I'm trying to relate two tables with a one to many relationship (the parent table has a composite primary key) but I'm getting a mapper error. I found a recent message about this same problem but with declarative base (which I don't use) and not sure why the suggestion there didn't apply to

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
. If 'secondary' is present, 'secondaryjoin' is needed as well. If I leave the primaryjoin I still get the same error as reported. TIA for any extra ideas you can suggest to fix this. Mariano On Nov 30, 2010, at 10:22 AM, Mariano Mara wrote: Hi. I'm trying to relate two tables with a one

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
RegEventWho(object): pass mapper(RegEvent, regevent, properties={ 'who': relationship(RegEventWho) }) mapper(RegEventWho, regevent_who) print Session().query(RegEvent).join(RegEvent.who) On Nov 30, 2010, at 12:22 PM, Mariano Mara wrote: Excerpts from Michael Bayer's message of Tue

[sqlalchemy] Error with ForeignKeyConstraint while reloading model

2010-09-29 Thread Mariano Mara
Hi. I have some (very simple) tables defined in my model, such as extensions = Table('ast_user_extension', metadata, Column(id, Integer, autoincrement=True, primary_key=True), Column(extension, Unicode(20), nullable=False),

[sqlalchemy] Problem with alias in SQL

2010-07-20 Thread Mariano Mara
Hi there, I have these two tables (with very long column names and most of them with the same names in both tables) I want to join. Since I will be processing the results afterwards, I would like to have shorten names to type less and clearly differentiated names to avoid conflicts. So I pass the

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Mariano Mara
Excerpts from zende's message of Thu Jul 08 13:27:27 -0300 2010: I reproduced the issue the script below: http://gist.github.com/468199 Sorry for the weak explanation before. This has little to do with being in tests except that's the only code that drops and creates the db for any reason.

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Mariano Mara
Excerpts from zende's message of Thu Jul 08 14:01:32 -0300 2010: Mariano, What db? postgres? On Jul 8, 9:41 am, Mariano Mara mariano.m...@gmail.com wrote: I'm on a similar situation. For lack of time I couldn't investigate it yet but I have a drop_all when running nosetests in my pylons

Re: [sqlalchemy] WITH RECURSIVE and ORM

2010-06-27 Thread Mariano Mara
Excerpts from Ergo's message of Sun Jun 27 14:11:58 -0300 2010: Hello, I'm looking for a way to execute a recursive query and get ORM instances with it. http://www.postgresql.org/docs/8.4/interactive/queries-with.html I know we don't have any direct support for recursive syntax in SA,

[sqlalchemy] Hierarchical queries with pgsql = 8.4.0

2010-05-26 Thread Mariano Mara
Hi everyone. I have been working in a little class that brings support for with recursive idiom in my project. Actually the part it supports for the moment are the necessary bits to generate hierarchical data (I thought somebody might find it useful too so I added it as a recipe in the wiki[1]).

Re: [sqlalchemy] Hierarchical queries with pgsql = 8.4.0

2010-05-26 Thread Mariano Mara
Excerpts from Michael Bayer's message of Wed May 26 13:23:01 -0300 2010: On May 26, 2010, at 11:47 AM, Mariano Mara wrote: Hi everyone. I have been working in a little class that brings support for with recursive idiom in my project. Actually the part it supports for the moment

Re: [sqlalchemy] oracle database error.

2010-04-27 Thread Mariano Mara
Excerpts from dhanil anupurath's message of Tue Apr 27 07:22:45 -0300 2010: I am using Sqlalchemy with Oracle backend in my project. I am running into listener issues with the Oracle database. Here are the steps that I am following: 1. My connection string.

Re: [sqlalchemy] about commit()

2010-04-23 Thread Mariano Mara
Excerpts from jo's message of Fri Apr 23 03:16:21 -0300 2010: Hi all, I need to insert a new row and get back the last inserted id, I have some difficulty using the flush(), then I'm trying with commit() but I can't understand how commit() works in 0.6. In the following script I try to

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Mariano Mara
Excerpts from Chris Withers's message of Thu Apr 15 11:46:05 -0300 2010: Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values, they don't, and it may vary from when

Re: [sqlalchemy] identifier is too long

2010-03-30 Thread Mariano Mara
Excerpts from jo's message of Tue Mar 30 03:25:18 -0300 2010: Hi all, I have some troubles creating my db schema with Oracle. The problem is on this column: Column('cod_caratteristica_rischio', Unicode(10), index=True, nullable=False) It works fine in PostgreSQL but when I try it on

Re: [sqlalchemy] Column type in select w/ if condition

2010-03-30 Thread Mariano Mara
Excerpts from Bryan's message of Tue Mar 30 11:27:57 -0300 2010: The underlying column returns a Decimal object when queried regularly, and when summed as follows: select([ mytable.c.hours ]) Decimal(1.0) select([ func.sum(mytable.c.hours) ]) Decimal(1.0) ...but when I sum it w/ an if

Re: [sqlalchemy] Re: (Workaround found and SA bug with localhost?) error connecting to remote mysql database

2010-03-25 Thread Mariano Mara
Excerpts from Richard de Koning's message of Thu Mar 25 15:50:45 -0300 2010: I've done some troubleshooting and these are my preliminary conclusions. A ssh-tunnel is used to reach the remote MySQL database server that only runs on 127.0.0.1 (localhost). Commands sent to 127.0.0.1 port 3307

Re: [sqlalchemy] Re: Multiple table query ?

2009-12-22 Thread Mariano Mara
Excerpts from gsandorx's message of Tue Dec 22 16:03:44 -0300 2009: Hi Mariano, I tried your code and it worked great. Now I have to look a way of linking the union query with a mapper to obtain a rather elaborate object than a raw tuple, I mean, when you execute: q =

Re: [sqlalchemy] easy_install SQLAlchemy

2009-12-01 Thread Mariano Mara
Excerpts from Tefnet Developers - Tomasz Jezierski's message of Tue Dec 01 19:06:31 -0300 2009: Dnia 2009-12-01, Wt o godzinie 18:45 +0100, Alexandre Conrad pisze: Hey there, just wondering: easy_install SQLAlchemy downloads and installs version 0.5.2. Shouldn't it be 0.5.6?

Re: [sqlalchemy] Weird error with update

2009-11-21 Thread Mariano Mara
Excerpts from Mike Conley's message of Sat Nov 21 03:36:07 -0300 2009: On Fri, Nov 20, 2009 at 5:14 PM, Mariano Mara mariano.m...@gmail.comwrote: ... or, at least, is weird for me :) Hi everyone. I'm running a pylons controller with the following instruction: meta.Session.query

[sqlalchemy] Weird error with update

2009-11-20 Thread Mariano Mara
... or, at least, is weird for me :) Hi everyone. I'm running a pylons controller with the following instruction: meta.Session.query(ESMagicNumber).filter( ESMagicNumber.uuid==request.params['uuid_']).\ update({'last_access':datetime.datetime.now()}) but I'm

[sqlalchemy] outer join with two clauses

2009-10-27 Thread Mariano Mara
Hi everyone, how do I use two clauses in an outerjoin? e.g.: select ... from t1 outer join t2 on (t1.c1=t2.c1 and t1.c2t2.c2) According to docs, outerjoin is outerjoin(left, right, onclause=None) so I don't really know where to place the second clause. In a query object, outerjoin is