[sqlalchemy] strange serial problem in postgres

2007-08-17 Thread Glauco
Hi all, i've added a new table recentli in main DB, but at first insertion have this problem: any time i try an insertion the sqlalchemy engine search nextval of a partial primary key. SQLError: (ProgrammingError) relation scadenziario_id_piano_seq does not exist 'select

[sqlalchemy] Re: large amount of insert

2007-08-17 Thread sdobrev
there was some recent thread on this 2-3 weeks ago, lookup.. On Friday 17 August 2007 11:28:34 Glauco wrote: What's is the best solution for a web procedure , in TurboGear, that produce a large amount of insert into ? (from 2000 to 2 insertions on a submit) i've done some try with

[sqlalchemy] Join vs. 2 selects?

2007-08-17 Thread Martin
Hi all, This is sort of a general db question I was wondering about. So, I'm trying to write a small blog system (not using the mapper, only sql queries written on my own until now) and I am not sure: Say, I want to show one blog post and all the comments for that blog entry (one-to-many). I

[sqlalchemy] Re: sqlalchemy 0.4 beta3 released

2007-08-17 Thread Christophe de VIENNE
Hi, Any chance Ticket #731 get into 0.4 ? I'd prefer not relying on a patch if possible. Thanks a lot, Christophe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: Join vs. 2 selects?

2007-08-17 Thread Alexandre CONRAD
Martin wrote: a) 2 separate select-queries? One query going like: SELECT * from blog_posts WHERE post_id = my_post_id and the other sth. like SELECT * from comments WHERE parent_id = my_post_id. b) one join-query? Joining the two tables over my_post_id, so I only need 1 sql-query? Two

[sqlalchemy] Re: strange serial problem in postgres

2007-08-17 Thread Michael Bayer
On Aug 17, 2007, at 4:21 AM, Glauco wrote: SQLError: (ProgrammingError) relation scadenziario_id_piano_seq does not exist 'select nextval(\'scadenziario_id_piano_seq\')' {} but the table is: CREATE TABLE scadenziario ( id_pianoINTEGER NOT NULL

[sqlalchemy] Re: strange serial problem in postgres

2007-08-17 Thread justanyone
In Postgres at least, serial columns are typically defined as: CREATE TABLE FOO ( id_piano serial primary key, ... ) This automatically creates a sequence foo_id_piano_seq. Of course, you can also create a sequence separate from a table with CREATE SEQUENCE, but this is (IMHO) wordy.

[sqlalchemy] Re: strange serial problem in postgres

2007-08-17 Thread Glauco
justanyone ha scritto: In Postgres at least, serial columns are typically defined as: CREATE TABLE FOO ( id_piano serial primary key, ... ) This automatically creates a sequence foo_id_piano_seq. Of course, you can also create a sequence separate from a table with CREATE SEQUENCE,

[sqlalchemy] sqlalchemy + django

2007-08-17 Thread imgrey
Could someone please explain the following behaviour: from django.http import HttpResponseRedirect, Http404 from django.shortcuts import render_to_response from df.tst import Path as ThePath from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData() u_table = Table('auth_user',

[sqlalchemy] Re: sqlalchemy 0.4 beta3 released

2007-08-17 Thread Paul Johnston
Hi, Any chance Ticket #731 get into 0.4 ? I'd prefer not relying on a patch if possible. I'd applied this to trunk and rel_0_3. I don't have alert mails setup from trac (maybe I should) so if you drop me a mail when you want an MSSQL patch looking at, I'll do my best. Paul

[sqlalchemy] Re: Join vs. 2 selects?

2007-08-17 Thread Michael Bayer
the traditional wisdom is that the join is faster, because you have fewer round trips to the database. particularly if you are loading many parent items each with many child items. if you are loading just a single parent item, the second SELECT to get its child items is not a very large hit at

[sqlalchemy] Re: sqlalchemy + django

2007-08-17 Thread Michael Bayer
its a pickling error. Pickle is not managing to map your pickled data back to the correct module name from which to import the Path object.If this module (i.e., where the Path class originates) is run by django in some kind of dynamic importing scheme, that could definitely break pickle's

[sqlalchemy] Re: sqlalchemy + django

2007-08-17 Thread Vitaliyi
On 8/17/07, Michael Bayer [EMAIL PROTECTED] wrote: its a pickling error. Pickle is not managing to map your pickled data back to the correct module name from which to import the Path object.If this module (i.e., where the Path class originates) is run by django in some kind of dynamic

[sqlalchemy] Re: sqlalchemy 0.4 beta3 released

2007-08-17 Thread Christophe de VIENNE
2007/8/17, Paul Johnston [EMAIL PROTECTED]: Hi, Any chance Ticket #731 get into 0.4 ? I'd prefer not relying on a patch if possible. I'd applied this to trunk and rel_0_3. I don't have alert mails setup from trac (maybe I should) so if you drop me a mail when you want an MSSQL patch

[sqlalchemy] Re: large amount of insert

2007-08-17 Thread Michael Bayer
well at the very least you want to ensure that executemany() is being used for the inserts (i.e. with sqlalchemy, dont use ORM, use connection.execute(statement, [param, param, param...]). If you use SQLAlchemy's executemany() facilities, we've just increased their efficiency by about 60% in the

[sqlalchemy] Re: strange serial problem in postgres

2007-08-17 Thread Marco Mariani
Glauco ha scritto: Thank you kevin , i've worked a lot over PG and this tecnique is consolidated in our model.. but here the problem is that the column is a simplycolumn_name INTEGER NOT NULL references other_table(id) and i cannot understand why sqlalchemy whant to use it as a

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Marco Mariani
Lukasz Szybalski ha scritto: bind_meta_data() users_table = Table('users', metadata, autoload=True) class Users(object): pass usersmapper=mapper(Users,users_table) assign_mapper() in place of mapper() mysession=session.query(Users) 1. What would be the code from now on to

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Lukasz Szybalski
hello - you generally use mapper() and relation() to set up how you'd like your classes to correspond to your table relationships. as far as compound keys, if they are defined with a primary key constraint you shouldn't have to worry about them. --- Ok. So we are using mapper()

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Lukasz Szybalski
ok...correct me if I'm wrong. #we start by importing from turbogears.database import metadata, session,bind_meta_data from sqlalchemy.ext.assignmapper import assign_mapper from turbogears import widgets, validators import sqlalchemy #Then we bound to database bind_meta_data() #create a table

[sqlalchemy] Re: Joining multiple tables

2007-08-17 Thread Vetle Roeim
On 8/17/07, Michael Bayer [EMAIL PROTECTED] wrote: hi Vetle - the Table object supports a join() method, which can be called in a chain, i.e. table1.join(table2).join(table3)... if you need to specify the ON part of the join, its the second argument to join() (below illustrated with

[sqlalchemy] Re: sqlalchemy + django

2007-08-17 Thread Michael Bayer
On Aug 17, 11:54 am, Vitaliyi [EMAIL PROTECTED] wrote: I've tried this : import psycopg2 ... s = curs.fetchone()[0] ls = cPickle.loads(str(s)) and it returned : AttributeError: 'module' object has no attribute 'Path' just as django did. it pretends that 'Path' is not defined. Seems