[sqlalchemy] statement profiling on production

2009-02-12 Thread Diez B. Roggisch
Hi, with our old homegrown SQL-wrapping we enjoyed the possibility to time each sql-query to drill down on performance bottlenecks. This is currently not possible for us using SA. So I'd like to ask how to approach this. I found some references on the net talking about profiling in

[sqlalchemy] pool connection concurrently

2009-02-12 Thread Rodrigo Faccioli
Hi, This is my first post. I want to know, if is possible, I connect to postgresql at the same time. Example: I have a webpage which shows five results that their data have stored in the same database or not (but all postgresql). So, my idea is using sqlalchemy pool connection call these five

[sqlalchemy] Re: statement profiling on production

2009-02-12 Thread Michael Bayer
recipe which sounds similar to your old approach here: http://techspot.zzzeek.org/?p=31 On Feb 12, 2009, at 5:27 AM, Diez B. Roggisch wrote: Hi, with our old homegrown SQL-wrapping we enjoyed the possibility to time each sql-query to drill down on performance bottlenecks. This is

[sqlalchemy] Re: pool connection concurrently

2009-02-12 Thread Michael Bayer
a single pool expects to connect to a single database URL, since it pools all connections equally and doesn't store details regarding the characteristics of individual connections. If you want to pull results from multiple databases, you'd have to use multiple pool and/or Engine objects

[sqlalchemy] sqlsoup + with_labels not working on one table?

2009-02-12 Thread Stuart Axon
I've got a fairly simple database made with django and accessed via sqlsoup. (finally got some time to take more of a look at the tutorial, which helped a little :) The two tables are devmap_device id device_name manufacturer_id devmap_manufacturer id manufacturer_name I tried to

[sqlalchemy] werid error with session.merge

2009-02-12 Thread Chris Withers
Hi All, Can someone tell me why this script: from datetime import datetime from sqlalchemy import create_engine, Table, Column, Integer, String, DateTime, ForeignKey from sqlalchemy.orm import sessionmaker, relation, backref from sqlalchemy.ext.declarative import declarative_base engine =

[sqlalchemy] Re: werid error with session.merge

2009-02-12 Thread Michael Bayer
On Feb 12, 2009, at 12:09 PM, Chris Withers wrote: session = sessionmaker(bind=engine)() unit = Unit(id=1,name='unit 1') session.merge(unit) session.add(Record( timestamp = datetime.now(), unit = unit, )) session.merge(Unit(id=2,name='unit 2'))

[sqlalchemy] Re: werid error with session.merge

2009-02-12 Thread Chris Withers
Michael Bayer wrote: On Feb 12, 2009, at 12:09 PM, Chris Withers wrote: session = sessionmaker(bind=engine)() unit = Unit(id=1,name='unit 1') session.merge(unit) session.add(Record( timestamp = datetime.now(), unit = unit, ))

[sqlalchemy] dev: dialect reflection methods

2009-02-12 Thread Randall Smith
I've been working on breaking Dialect.reflecttable into components so that they can be used independently (e.g. get_columns, get_foreign_keys, etc). One of the original goals was to be able to do away with reflecttable and have the Inspector, engine.reflection.Inspector, construct the table

[sqlalchemy] Re: Problem with inheritance and cross relations (was: Unable to model cross relations (using ext.declarative))

2009-02-12 Thread Bruce van der Kooij
Many thanks Michael, your instructions were spot-on. In the process of following your instructions I decided to switch from using ext.declarative to a non-declarative style (define tables, define Python objects, setting up the mapping, the works :-). Regretfully while trying to work out the rest

[sqlalchemy] Re: Problem with inheritance and cross relations (was: Unable to model cross relations (using ext.declarative))

2009-02-12 Thread az
is this joined inheritance or concrete? IMO if Product inherits Node, they has to have same PK? On Thursday 12 February 2009 23:56:12 Bruce van der Kooij wrote: Many thanks Michael, your instructions were spot-on. In the process of following your instructions I decided to switch from using

[sqlalchemy] Finding the latest matching object from a relationship?

2009-02-12 Thread Chris Withers
Hi All, With the model from my previous post, I'm looking to find the latest Record for a particular Unit. Someone on #sqlalchemy suggested this: unit = session.query(Unit).filter(Unit.id==3).first() record = unit.records.order_by(Record.date.desc()).first() ...however, this gives me:

[sqlalchemy] Re: Finding the latest matching object from a relationship?

2009-02-12 Thread Chris Withers
Chris Withers wrote: record = unit.records.order_by(Record.date.desc()).first() oops, I meant: record = unit.records.order_by(Record.timestamp.desc()).first() ...however, this still gives me: AttributeError: 'InstrumentedList' object has no attribute 'order_by' How should I be looking to do

[sqlalchemy] Re: Finding the latest matching object from a relationship?

2009-02-12 Thread az
use the relation as a join path, and then whatever filtering/ordering try: unit.join(Unit.records).order_by(Record.date.desc()).first() or unit.join('records').order_by(Record.date.desc()).first() --~--~-~--~~~---~--~~ You received this message because