[sqlalchemy] Extracting metadata about results

2007-04-12 Thread bjpirt
Hi, I am using sqlalchemy with pylons and I am trying to extract some metadata about the set of relationships between the objects I have defined. Specifically, I am trying to work out how to tell what kind of objects are held in a one to many relationship. e.g. Two classes - person and phone num

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread Kaali
I actually tried to use query.instances, but it behaved quite oddly. I didn't debug or even echo the SQL calls yet, but it made accessing those instances very slow. The actual instances call was quick, but when accessing the objects from the resulting list it slowed down to crawl. I will recreate

[sqlalchemy] Re: Bit strange - no expunge required?

2007-04-12 Thread Arun Kumar PG
I think SessionContext makes senses especially for architecture involving multiple layers like mine where manager <-> DAO interaction happens. Thx Michael. On 4/12/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > On Apr 11, 2007, at 11:15 PM, Arun Kumar PG wrote: > > > Hi Michael, > > > > So

[sqlalchemy] Re: Column to default to itself

2007-04-12 Thread Ants Aasma
On Apr 13, 2:47 am, Jorge Godoy <[EMAIL PROTECTED]> wrote: > IF you insist on doing that at your code, make the column UNIQUE (or a > PK...) and write something like this pseudocode: > > def save_data(): > def insert_data(): >try: >unique_column_value = get_

[sqlalchemy] Re: Column to default to itself

2007-04-12 Thread Jorge Godoy
"Koen Bok" <[EMAIL PROTECTED]> writes: > I need to have a uninterrupted number sequence in my table for > invoices. I was trying to do it like this, but I can't get it to work. > Can anyone give me a hint? Let your database do the job. It is always aware of all connections made to it, their con

[sqlalchemy] Column to default to itself

2007-04-12 Thread Koen Bok
I need to have a uninterrupted number sequence in my table for invoices. I was trying to do it like this, but I can't get it to work. Can anyone give me a hint? request_table = Table('request', metadata, Column('id', Integer, primary_key=True), Column('number', Integer, unique=Tru

[sqlalchemy] Re: Data from mysql db not returned by query

2007-04-12 Thread Michael Bayer
an engine uses a connection pool in all cases for all connections. On Apr 12, 2007, at 4:29 PM, vinjvinj wrote: > >> conn = mysql.db.connect() >> >> >> >> conn.close() > > > Thanks. That fixed the problem. Is sqlalchemy using a connection pool > when I do this or is a new connection o

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread Michael Bayer
there you go. On Apr 12, 2007, at 4:31 PM, ml wrote: > > I'm such a moron. I downloaded the SA source into a "sqlalchemy3" > directory but the SA expects it in a "sqlalchemy" package so it was > internaly loading the old 0.2.8 Ubuntu version. > > Sorry! :-) > > > Michael Bayer napsal(a): >> >>

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread Michael Bayer
it runs for me with 0.3.6 and the trunk. the end of the output is: 2007-04-12 16:57:20,733 INFO sqlalchemy.engine.base.Engine.0x..b0 SELECT addresses.id_user AS addresses_id_user, addresses.id AS addresses_id, addresses.addr AS addresses_addr FROM addresses, users WHERE (users.id = ?) AND us

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread ml
I'm such a moron. I downloaded the SA source into a "sqlalchemy3" directory but the SA expects it in a "sqlalchemy" package so it was internaly loading the old 0.2.8 Ubuntu version. Sorry! :-) Michael Bayer napsal(a): > > On Apr 12, 2007, at 12:53 PM, ml wrote: > >> I tried s.query(Address).s

[sqlalchemy] Re: Data from mysql db not returned by query

2007-04-12 Thread vinjvinj
> conn = mysql.db.connect() > > > > conn.close() Thanks. That fixed the problem. Is sqlalchemy using a connection pool when I do this or is a new connection opened and closed each time? Vineet --~--~-~--~~~---~--~~ You received this message because y

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread ml
See attachment. Tested against 0.3.6. Michael Bayer napsal(a): > > On Apr 12, 2007, at 12:53 PM, ml wrote: > >> I tried s.query(Address).select_by(user=u) as I found similar in the >> documentation >> (http://www.sqlalchemy.org/docs/ >> datamapping.html#datamapping_selectrelations_relselectby

[sqlalchemy] Re: splitting a relation into multiple properties

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 2:03 PM, jason kirtland wrote: > > > The 'analysis' relation is backed by a dict-like > collection_class keyed by the type of instance, and storing them > in a special list type that updates the ordering attribute. > 'analysis' isn't accessed directly by user code. > > # lo

[sqlalchemy] splitting a relation into multiple properties

2007-04-12 Thread jason kirtland
I'm trying to map a single relation onto multiple properties. Let's say I'm tracking "ideas", and a numbered list of pros and cons for each idea: Idea: beer Pros: 1. tastes great 2. less filling Cons: 1. warning: may not be true Or in SQL: Table('Ideas', metadata, Co

[sqlalchemy] Re: selecting from a relation

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 12:53 PM, ml wrote: > I tried s.query(Address).select_by(user=u) as I found similar in the > documentation > (http://www.sqlalchemy.org/docs/ > datamapping.html#datamapping_selectrelations_relselectby) > but SA raises: > AttributeError: 'LazyLoader' object has no attribute '

[sqlalchemy] Re: query().filter_by(boolean)

2007-04-12 Thread Michael Bayer
please file a ticket for this. (Query should raise exceptions for non-ClauseElements passed) On Apr 12, 2007, at 12:02 PM, Marco Mariani wrote: > > I'm not trying the trunk, and it's the first time I use filter_by, > but I > guess: > > MappedClass.query().filter_by( MappedClass.column_name

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread Michael Bayer
it needs to fire off the query to see whats changed when you go to flush(). otherwise it has no ability to know what needs to be saved. On Apr 12, 2007, at 11:43 AM, svilen wrote: > > while on the same subject, how do i copy one object's relatives to > another object without loading them all?

[sqlalchemy] Re: Data from mysql db not returned by query

2007-04-12 Thread Michael Bayer
just do this: conn = mysql.db.connect() conn.close() On Apr 12, 2007, at 11:34 AM, vinjvinj wrote: > mysql.conn = mysql.db.connect() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group

[sqlalchemy] selecting from a relation

2007-04-12 Thread ml
Hi! Lets have: ## users_table = Table("users", metadata, Column("id", Integer, primary_key=True), Column("user_name", String(16)) ) addresses_table = Table("addresses", metadata, Column("id", Integer, primary_key=True), Column("id_user", Integer, ForeignKey("u

[sqlalchemy] sqlite + timezone oddities

2007-04-12 Thread Arthur Clune
I'm having issues with sqlite and DateTime objects with a timezone attached (python 2.5, SQA 0.3.6, pysqlite-2.3.3, OS X) crashing, but the code works with postgres. I get the same issue with Python 2.4. Given the test code below, with postgres I get # Via object 1970-01-01 06:30:34+00:

[sqlalchemy] Building multiple filter criteria through relations for a Query object

2007-04-12 Thread Evert Rol
(Apologies for the somewhat long-winded subject line; should cover the whole question though.) Hi folks, I'm new to SQLAlchemy, and rather new to SQL in general, so I've been stumbling along trying to get a Pylons project of the ground (using the SQLAlchemy setup as outlined at http://www.r

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread Ants Aasma
On Apr 12, 6:37 pm, svilen <[EMAIL PROTECTED]> wrote: > how about whatever.in() -> (whatever and False) > maybe problem with Null then? (null and false) gives false, so not(null and false) is true. This means that not_(col.in_()) returns all rows, while not_(col.in_(nonexistantvalue)) returns all

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread svilen
sorry, ignore this, started a new thread --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL

[sqlalchemy] many2many: how to copy one object's relatives to another object ?

2007-04-12 Thread svilen
how do i copy one object's relatives to another object, and if possible without loading them all? 1. user1.addresses = user2.addreses does not work, it makes them share the same InstrList 2. user1.addresses = user2.addreses[:] does work, but fires a full query (maybe with obj-instantiation) T

[sqlalchemy] query().filter_by(boolean)

2007-04-12 Thread Marco Mariani
I'm not trying the trunk, and it's the first time I use filter_by, but I guess: MappedClass.query().filter_by( MappedClass.column_name == 'Foo' ) equates to filter_by(False), because the .c is missing and it's comparing an UOWProperty to a string, instead of a Column object to a string Actually

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread svilen
while on the same subject, how do i copy one object's relatives to another object without loading them all? user1.addresses = user2.addreses does not work, it makes them share the same InstrList user1.addresses = user2.addreses[:] does work, but fires a full query (maybe with obj-instantiatio

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread svilen
how about whatever.in() -> (whatever and False) maybe problem with Null then? On Thursday 12 April 2007 18:23:38 Michael Bayer wrote: > On Apr 12, 2007, at 9:46 AM, Ants Aasma wrote: > > On Apr 12, 1:59 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > >> agreed, as long as we know that saying "som

[sqlalchemy] Re: Data from mysql db not returned by query

2007-04-12 Thread vinjvinj
> each query, or just returning it to the connection pool via close() > (which also calls rollback()) and then re-acquiring it from the pool > as needed. I have a wrapper function called execute() whcih traps any errors and then recreates the mysql engine object and tries to resubmit the qry: de

[sqlalchemy] Re: Data from mysql db not returned by query

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 10:31 AM, vinjvinj wrote: > The problem is that the data is not seen by the second application > server. When I log into to mysql from my desktop I CAN see the data. > The problem goes away when I restart the application server with sql- > alchemy. I'm caching the mysql.db co

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 9:46 AM, Ants Aasma wrote: > > On Apr 12, 1:59 am, Michael Bayer <[EMAIL PROTECTED]> wrote: >> agreed, as long as we know that saying "somecolumn != somecolumn" is >> valid and produces False on all dbs (including frequent-offenders >> firebird and ms-sql) ? (thats how you i

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 3:32 AM, svilen wrote: > it, but if it's once in a blue moon, u'll get one more disappointed > SA user ;0(. right, and then i dont find out until i meet them at Pycon ;) --~--~-~--~~~---~--~~ You received this message because you are subs

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread Michael Bayer
On Apr 12, 2007, at 3:30 AM, Kaali wrote: > > Thanks for the answers. > > I implemented message loading with find_members() kind of method, as > shown in the documentation link you gave, and it got twice as fast. > But it's still nowhere near the speed without the ORM. i get the impression your

[sqlalchemy] Re: Bit strange - no expunge required?

2007-04-12 Thread Michael Bayer
On Apr 11, 2007, at 11:15 PM, Arun Kumar PG wrote: > Hi Michael, > > So how can I prevent this as I can't access the lazyload attributes > in my manager class once I get the result set from DAO as i get no > parent session/contextual session exists exception. > > should I maintain a referenc

[sqlalchemy] Re: just what does 'delete-orphan' bring us ?

2007-04-12 Thread Frederic Vander Elst
Thanks very much, all clear now. -f --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PR

[sqlalchemy] Re: sqlalchemy.orm.attributes.InstrumentedList

2007-04-12 Thread svilen
same way, recursively: check 1st element if mylist and isinstance( mylist[0], yourlisttype): ... or check all elements, or... On Thursday 12 April 2007 17:52:28 Disrupt07 wrote: > Thanks. 'if isinstance(your_object, > sqlalchemy.orm.attributes.InstrumentedList):' was helpful to me. > > Now I w

[sqlalchemy] Re: sqlalchemy.orm.attributes.InstrumentedList

2007-04-12 Thread Disrupt07
Thanks. 'if isinstance(your_object, sqlalchemy.orm.attributes.InstrumentedList):' was helpful to me. Now I want to check if the given list is either a list of elements or a list of lists. Example: list1 = ['a', 'b', 'c'] list2 = [['a', 'b'], ['c', 'd'], ['e']] How can I check for lists within a

[sqlalchemy] Data from mysql db not returned by query

2007-04-12 Thread vinjvinj
Hi Guys, I'm stumped with this and would appreciate any insight. I'm using mysql.db = create_engine('mysql://%s:[EMAIL PROTECTED]/%s' % (config.DB_USER, config.DB_PASS, config.DB_HOST, config.DB_NAME)) mysql.conn = mysql.db.connect() mysql.conn.execute(qry) I have three servers. Two application

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread Ants Aasma
On Apr 12, 1:59 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > agreed, as long as we know that saying "somecolumn != somecolumn" is > valid and produces False on all dbs (including frequent-offenders > firebird and ms-sql) ? (thats how you interpreted IN (), right ?) It works (almost) ok in MSSQ

[sqlalchemy] Re: sqlalchemy.orm.attributes.InstrumentedList

2007-04-12 Thread King Simon-NFHD78
Disrupt07 wrote > > What is sqlalchemy.orm.attributes.InstrumentedList? > > I need to use the sqlalchemy.orm.attributes.InstrumentedList type in > my Python controller methods and need to check if the type of another > object is of type sqlalchemy.orm.attributes.InstrumentedList. How can > I d

[sqlalchemy] Re: 'PropertyLoader' object has no attribute 'strategy'

2007-04-12 Thread Roger Demetrescu
Hi Michael, As Simon suggested, I am now using log.except() instead log.error(), so I hope the next exception will be followed by more information. Thanks On 4/11/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > On Apr 11, 2007, at 1:46 AM, Roger Demetrescu wrote: > > > > > Hi all, > > > >

[sqlalchemy] sqlalchemy.orm.attributes.InstrumentedList

2007-04-12 Thread Disrupt07
What is sqlalchemy.orm.attributes.InstrumentedList? I need to use the sqlalchemy.orm.attributes.InstrumentedList type in my Python controller methods and need to check if the type of another object is of type sqlalchemy.orm.attributes.InstrumentedList. How can I do this? (e.g. using the type() f

[sqlalchemy] Re: IN() bug bit hard

2007-04-12 Thread svilen
just my point of view: generatively, i would probably do .in_( somelist ), where somelist is a variable, and it will work fine until that list gets empty. If that happens frequently, okay, i'll know soon about it and fix it/avoid it, but if it's once in a blue moon, u'll get one more disappoint

[sqlalchemy] Re: Many to many optimization

2007-04-12 Thread Kaali
Thanks for the answers. I implemented message loading with find_members() kind of method, as shown in the documentation link you gave, and it got twice as fast. But it's still nowhere near the speed without the ORM. Makes me a bit sad, as i really liked the ORM system. Maybe if i remove any autom