[sqlalchemy] Re: mapping of Wordpress taxonomy tables

2008-05-06 Thread Max Ischenko
On 5 май, 11:55, Max Ischenko [EMAIL PROTECTED] wrote: Hello, My python app uses Wordpress blog database and my sqlalchemy mappings recently broke due to Wordpress update. Can someone pls help to map the following taxonomy tables into SA? I've tried to follow Specifying Alternate Join

[sqlalchemy] table union through ORM

2008-05-06 Thread Eric Lemoine
Hello Here's my thing: I have two DB tables, refugees and offices, which are independent tables (no foreign key). I already have two mappers for those tables: mapper(Refugee, refugees_table) mapper(Office, offices_table) In addition to being able to do independent queries on each table, I'd

[sqlalchemy] Re: column name must be lowercase for CheckConstraint.

2008-05-06 Thread Michael Bayer
can you file a trac ticket with a short example, please. On May 5, 2008, at 10:39 PM, James Su wrote: If you define a column with column name contains capital letter, and define CheckConstraint for this column, then DDL issued by SA will be wrong.

[sqlalchemy] Re: mapping of Wordpress taxonomy tables

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 3:19 AM, Max Ischenko wrote: On 5 май, 11:55, Max Ischenko [EMAIL PROTECTED] wrote: Hello, My python app uses Wordpress blog database and my sqlalchemy mappings recently broke due to Wordpress update. Can someone pls help to map the following taxonomy tables into SA?

[sqlalchemy] Re: table union through ORM

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 7:49 AM, Eric Lemoine wrote: Hello Here's my thing: I have two DB tables, refugees and offices, which are independent tables (no foreign key). I already have two mappers for those tables: mapper(Refugee, refugees_table) mapper(Office, offices_table) In addition to

[sqlalchemy] How to ignore primary key errors on insert

2008-05-06 Thread Alexis B
Hi to all, This may be a newbie question but I just can't find the answer. I have to make multiple submissions to a postgresql table and I want to use python. I found everything to execute my insert commands, the problem is that I have to repeat it regularly, and I expected not to check which

[sqlalchemy] ProgrammingError: Can't adapt INSERT

2008-05-06 Thread Nagarajan
All, I am a newbie to SQLAlchemy. I needed an ORM for my system and after a research, I decided on SQLAlchemy. I used SQLAutocode that generated this model.py (a snippet is pasted here) - X-- Sources

[sqlalchemy] Re: ProgrammingError: Can't adapt INSERT

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 6:17 AM, Nagarajan wrote: All, I am a newbie to SQLAlchemy. I needed an ORM for my system and after a research, I decided on SQLAlchemy. I used SQLAutocode that generated this model.py (a snippet is pasted here) -

[sqlalchemy] Re: How to ignore primary key errors on insert

2008-05-06 Thread Michael Bayer
just use try/except from sqlalchemy import exceptions try: engine.execute(mytable.insert(), **kwargs) except exceptions.IntegrityError, e: print Error !, e, well, I guess we'll ignore it. engine.execute(some_other_insert_statement ... ) On May 6, 2008, at 10:06 AM, Alexis B wrote:

[sqlalchemy] Re: mapping of Wordpress taxonomy tables

2008-05-06 Thread Max Ischenko
On 5/6/08, Michael Bayer [EMAIL PROTECTED] wrote: mapper(WordpressPost, wp_posts_tbl, properties={ 'categories': relation(WordpressTaxonomy, primaryjoin= and_(wp_terms_taxonomy_tbl.c.taxonomy=='category', wp_term_relationships_tbl

[sqlalchemy] Re: table union through ORM

2008-05-06 Thread Eric Lemoine
On Tue, May 6, 2008 at 4:24 PM, Michael Bayer [EMAIL PROTECTED] wrote: On May 6, 2008, at 7:49 AM, Eric Lemoine wrote: Hello Here's my thing: I have two DB tables, refugees and offices, which are independent tables (no foreign key). I already have two mappers for those

[sqlalchemy] query.all() returns None?

2008-05-06 Thread dgriff1
Hi, I have been using SQLAlchemy with Pylons. I map a table to a class and use ORM(reflection) to work with it. I am using MySQL for the backend. The class is Job and the table is jobs. I can create and insert new Jobs but whenever I try to get any back I get None. This used to work just fine

[sqlalchemy] Re: table union through ORM

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 11:13 AM, Eric Lemoine wrote: In the Concrete Table Inheritance example in the doc, there's an employee table. In my case, there's no location table, and that's why I haven't seen Concrete Table Inheritance as my case's solution. So I'm still confused on how I'm going to

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 11:17 AM, [EMAIL PROTECTED] wrote: Hi, I have been using SQLAlchemy with Pylons. I map a table to a class and use ORM(reflection) to work with it. I am using MySQL for the backend. The class is Job and the table is jobs. I can create and insert new Jobs but whenever I

[sqlalchemy] Re: table union through ORM

2008-05-06 Thread Eric Lemoine
Thanks a lot. I'll try that 2008/5/6, Michael Bayer [EMAIL PROTECTED]: On May 6, 2008, at 11:13 AM, Eric Lemoine wrote: In the Concrete Table Inheritance example in the doc, there's an employee table. In my case, there's no location table, and that's why I haven't seen Concrete Table

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread dgriff1
No, I do implement a __str__ so that I can format up the composite primary key. I didnt implement __repr__ at all. Dan On May 6, 10:25 am, Michael Bayer [EMAIL PROTECTED] wrote: On May 6, 2008, at 11:17 AM, [EMAIL PROTECTED] wrote: Hi, I have been using SQLAlchemy with Pylons. I map

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 11:42 AM, [EMAIL PROTECTED] wrote: No, I do implement a __str__ so that I can format up the composite primary key. I didnt implement __repr__ at all. Ok you'd have to work up an example script that can illustrate this happening, I can't see any codepath that would

[sqlalchemy] Re: mapping of Wordpress taxonomy tables

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 11:12 AM, Max Ischenko wrote: Then I think this is a typo here: http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_customjoin_fks thanks this is fixed on the site and in r4663. --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread dgriff1
Ok, its pretty hard to really put an example script up, but heres the relelvant parts. #From the Model jobs_table = Table('jobs', metadata, autoload=True) mapper(Job, jobs_table ) #The Job Class is pretty generic so I wont include it #The method that does the display with a debug print def

[sqlalchemy] Re: Goofy Association Table

2008-05-06 Thread Matt Haggard
Thank you Michael! I've got a follow-up question if anyone's up to it. I've changed my classes and mappings to the following: class QType(object): ... questions = association_proxy('joinObj', 'questions', creator=_create_joinObj) sections = association_proxy('joinObj', 'sections')

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread Michael Bayer
that doesnt help much. We really need a standalone script which reproduces the behavior on its own. You'll probably find the issue yourself as you go through this process. On May 6, 2008, at 12:28 PM, [EMAIL PROTECTED] wrote: #From the Model jobs_table = Table('jobs', metadata,

[sqlalchemy] Re: query.all() returns None?

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 12:28 PM, [EMAIL PROTECTED] wrote: #Interactive debugger is stuff I executed print Session.query(Job).all() [None] print Session.query(Job).first() None heres other things to try. 1. you are on SQLAlchemy 0.4.5. 2. do not use any 3rd party Python REPL tools like

[sqlalchemy] Ordering results ina self-referential join

2008-05-06 Thread Moshe C.
Hi, Node is an orm mapped class, which is self-referential. myquery = Node.query() myquery = myquery.join('parent', aliased=True) myquery = myquery.filter(Node.c.desc.like('%something')) myquery = myquery.order_by(Node.c.name) The last line orders by the 'name' of the 2nd joined table. How

[sqlalchemy] Re: Ordering results ina self-referential join

2008-05-06 Thread Michael Bayer
On May 6, 2008, at 1:43 PM, Moshe C. wrote: Hi, Node is an orm mapped class, which is self-referential. myquery = Node.query() myquery = myquery.join('parent', aliased=True) myquery = myquery.filter(Node.c.desc.like('%something')) myquery = myquery.order_by(Node.c.name) The last line

[sqlalchemy] Re: Ordering results ina self-referential join

2008-05-06 Thread Moshe C.
Both methods cause a crash (yes, on 0.4.5) . converting a tuple to a list in sqlalchemy/orm/query.py fixes it for one of the methods, for the other you need to do the opposite, convert a list to a tuple. File '/home/moshe/top/webapp/rma/rma/controllers/list.py', line 215 in list_sources

[sqlalchemy] Re: table union through ORM

2008-05-06 Thread Eric Lemoine
On Tue, May 6, 2008 at 5:36 PM, Eric Lemoine [EMAIL PROTECTED] wrote: Thanks a lot. I'll try that It works great! I would never have found how to do it without support from you Michael. The doc wasn't explicit enough for me to figure it out by myself. But support on the mailing list is awesome

[sqlalchemy] Properly closing all database connections

2008-05-06 Thread Karlo Lozovina
I'm using SA with SQLite, and after executing session.close() and clear_mappers(), on Linux, lsof still says my SQLite file is open. Running engine.dispose() seems to finally close it, but I'm not sure if that's the proper way? Thanks, Karlo. --~--~-~--~~~---~--~~

[sqlalchemy] Re: Properly closing all database connections

2008-05-06 Thread jason kirtland
Karlo Lozovina wrote: I'm using SA with SQLite, and after executing session.close() and clear_mappers(), on Linux, lsof still says my SQLite file is open. Running engine.dispose() seems to finally close it, but I'm not sure if that's the proper way? That's correct. The engine holds the

[sqlalchemy] Re: Properly closing all database connections

2008-05-06 Thread az
yes, session/mappes are ORM level, metadata is lower and engine is lowest AFAIK. On Tuesday 06 May 2008 23:39:13 Karlo Lozovina wrote: I'm using SA with SQLite, and after executing session.close() and clear_mappers(), on Linux, lsof still says my SQLite file is open. Running engine.dispose()

[sqlalchemy] Re: Properly closing all database connections

2008-05-06 Thread Karlo Lozovina
On May 6, 10:53 pm, jason kirtland [EMAIL PROTECTED] wrote: That's correct.  The engine holds the connection pool and dispose() will close the connections it manages. Thanks... it's weird there's no mention of it in the docs. -- Karlo Lozovina - Mosor

[sqlalchemy] Re: Query Threading Issue

2008-05-06 Thread Michael Bayer
On May 4, 2008, at 10:59 AM, Paul Johnston wrote: Hi, I'm writing a ToscaWidget to do a kind of data grid. The way I've designed it so far, you pass an SA query object to the Widget when it's created. Then, each time it's displayed, it applies a few extra filters to the query and

[sqlalchemy] Re: Ordering results ina self-referential join

2008-05-06 Thread Moshe C.
I couldn't create a simple test case, but I have analyzed the cause of the problem. The order_by() method is sent a list as an argument, but the argument 'criterion' becomes a tuple because of the def order_by(self, *criterion) syntax. in the case of if self._aliases_tail: , 'criterion' becomes

[sqlalchemy] Re: mssql, Linux, unixODBC - Could not locate column in row for column

2008-05-06 Thread jason kirtland
Rick Morrison wrote: Sounds nice, thanks for the heads-up. There'll be opportunities for dialects to set up pool events as well. One of the things I'm looking to see is better reconnect support for dead database connections from network partitions, sql server restarts, etc. Is

[sqlalchemy] Re: mssql, Linux, unixODBC - Could not locate column in row for column

2008-05-06 Thread Rick Morrison
I was thinking of a user-level option for liveliness checking on pool checkout, with dialect-specific implementations (e.g. execute a 'SELECT 1', or something more efficient if the driver allows). Is that in line with what you were thinking? I had in mind something more of a optimistic /

[sqlalchemy] Re: Query Threading Issue

2008-05-06 Thread Paul Johnston
Hi Mike, ive thought about this, and the Query is not in fact tied very hard to a partcular Session (or at all). I think it would be workable for us to add a using_session() method to it, i.e.: The original workaround you suggested of using a callable works fine for now. A

[sqlalchemy] Re: mssql, Linux, unixODBC - Could not locate column in row for column

2008-05-06 Thread jason kirtland
Rick Morrison wrote: I was thinking of a user-level option for liveliness checking on pool checkout, with dialect-specific implementations (e.g. execute a 'SELECT 1', or something more efficient if the driver allows). Is that in line with what you were thinking? I had

[sqlalchemy] Re: Ordering results ina self-referential join

2008-05-06 Thread Michael Bayer
thats really weird. I dont have time to check this now but i added ticket 1027 to confirm. On May 6, 2008, at 5:22 PM, Moshe C. wrote: I couldn't create a simple test case, but I have analyzed the cause of the problem. The order_by() method is sent a list as an argument, but the

[sqlalchemy] Re: Ordering results ina self-referential join

2008-05-06 Thread Michael Bayer
OK you got it in r4673, sorry youre hitting all these (kinda weird) On May 6, 2008, at 7:20 PM, Michael Bayer wrote: thats really weird. I dont have time to check this now but i added ticket 1027 to confirm. On May 6, 2008, at 5:22 PM, Moshe C. wrote: I couldn't create a simple