[sqlalchemy] Re: polymorphic mapping with more than 2 level of inheritance

2007-01-25 Thread svilen

 Also, we've noticed (well, postgres did it), that the most internal
 select (for that same B-level) of the polymorphic_union has 2
 xxx.id AS id columns:

FYI, the problem is made by polymorphic_union() which does a 
per-column renaming select over the A.join(B), and because the join 
has both id's A.id and B.id, it renames both into id:

$$ selA = table_A.select( table_A.c.atype == 'A', )
$$ selB0= table_A.join( table_B)
$$ print '---',selB0
--- A JOIN B ON A.id = B.id

$$ selB = table_A.join( table_B).select( table_A.c.atype == 'B', )
$$ print '---',selB
--- SELECT A.name, A.id, A.atype, B.bdata, B.id 
FROM A JOIN B ON A.id = B.id 
WHERE A.atype = ?

$$ selAB = sql.union_all( selA, selB )
$$ print '---',selAB
--- SELECT A.name, A.id, A.atype 
FROM A 
WHERE A.atype = ? 
UNION ALL 
SELECT A.name, A.id, A.atype, B.bdata, B.id 
FROM A JOIN B ON A.id = B.id 
WHERE A.atype = ?

$$ aselA = selA.alias('ta')
$$ aselB = selB.alias('tb')

puAB = polymorphic_union( {'A':aselA, 'B':aselB }, None, 'pu')
print '---', str(puAB)

--- SELECT CAST(NULL AS TEXT) AS bdata, ta.atype, ta.name, ta.id 
FROM (SELECT A.name AS name, A.id AS id, A.atype AS atype 
FROM A 
WHERE A.atype = ?) AS ta 
UNION ALL 
SELECT tb.bdata, tb.atype, tb.name, tb.id 
FROM (SELECT A.name AS name, A.id AS id, A.atype AS 
atype, B.bdata AS bdata, B.id AS id 
FROM A JOIN B ON A.id = B.id 
WHERE A.atype = ?) AS tb


polymunion() sure can be fixed to avoid such duplications - but why 
the A.join(B) whould have them both .id's anyway?

ciao
svil

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] class-object-like attribute lookup

2007-01-25 Thread Christopher Arndt

Hi all,

I'm still learning SA, so please forgive me, if I'm asking something obvious or
have overlooked something in the docs...

The subject onyl gives a vague idea of what I'm trying to accomplish, but since
I couldn't find better term for it, I had trouble searching the lists, docs, 
etc.

Suppose I have an object 'Bookmark' mapped to a table 'bookmarks':

bookmarks_tbl = Table('bookmarks', metadata,
Column('id', Integer, primary_key=True),
Column('owner_id', Integer, ForeignKey('users.user_id')),
Column('parent_id', Integer, ForeignKey('bookmarks.id')),
Column('title', String(100)),
Column('description', String(1000)),
Column('url', String(250))
)

As you can see 'parent_id' is a self-referencing FK to the bookmarks table. The
idea now is to allow users to have their own copies of mapped 'Bookmark'
objects, that are a sort of child of an existing 'Bookmark' object and allow
them to overwrite certain columns like e.g. 'title' and 'description'. But if
the column is NULL, it should be looked up in the parent object/row. Sort-of
like in class/object attributes in Python classes.

I hope, I made it clear what I mean. Is this feasible? Is there support in SA
for this or has anybody done anything like this? Any pointers or ideas are very
much appreciated!

Cheers, Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Job Opening

2007-01-25 Thread Tim Van Steenburgh

Tower Hill Insurance Group http://www.thig.com (Gainesville, FL, USA)
=

JOB DESCRIPTION
-
We're looking for a talented, enthusiastic programmer to join our web
team.  You'll be responsible for supporting/enhancing our existing
real-time policy rating and issuance system, while helping us design
and build the next generation of the software.  The successful
candidate will be a team player who enjoys challenge and is
comfortable in a fast-paced environment.

RELEVANT TECHNOLOGIES
---
* Python, SQLAlchemy, TurboGears, Twisted, XML-RPC
* Java, Servlets, JSP
* XML, XHTML, XSL
* DHTML, JavaScript, AJAX, CSS
* Oracle, MySQL, JDBC, DBAPI
* SVN, Trac

Java and Python experience are required.  Experience developing web
applications (preferably using OOP techniques and MVC design patterns)
is also required.

INTERESTED?
--
* Email resume to [EMAIL PROTECTED]
* To learn more about Tower Hill Insurance Group, visit
http://www.thig.com/About.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Christopher Arndt

Karl Guertin schrieb:
 Looks like you want recursive single table inheritance [1].

It doesn't need to be recursive, just a two-level parent-child relation. And I
don't want to add any columns, so I was thinking that table inheritance is not
the right approach, but I'm not sure about that.

Chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Karl Guertin

On 1/25/07, Christopher Arndt [EMAIL PROTECTED] wrote:
 It doesn't need to be recursive, just a two-level parent-child relation. And I
 don't want to add any columns, so I was thinking that table inheritance is not
 the right approach, but I'm not sure about that.

I was thinking that you could check parent_id for null or not null and
map that way, but it doesn't look like  the polymorphic mapper can
handle that. Ah well.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Rick Morrison

You could do this in a single join using COALESCE on the fallback columns.

Rick

On 1/25/07, Karl Guertin [EMAIL PROTECTED] wrote:

 On 1/25/07, Christopher Arndt [EMAIL PROTECTED] wrote:
  It doesn't need to be recursive, just a two-level parent-child relation. 
  And I
  don't want to add any columns, so I was thinking that table inheritance is 
  not
  the right approach, but I'm not sure about that.

 I was thinking that you could check parent_id for null or not null and
 map that way, but it doesn't look like  the polymorphic mapper can
 handle that. Ah well.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Michael Bayer

COALESCEwow i need to read some SQL books again... :)

On Jan 25, 2007, at 11:17 AM, Rick Morrison wrote:


 You could do this in a single join using COALESCE on the fallback  
 columns.

 Rick

 On 1/25/07, Karl Guertin [EMAIL PROTECTED] wrote:

 On 1/25/07, Christopher Arndt [EMAIL PROTECTED] wrote:
 It doesn't need to be recursive, just a two-level parent-child  
 relation. And I
 don't want to add any columns, so I was thinking that table  
 inheritance is not
 the right approach, but I'm not sure about that.

 I was thinking that you could check parent_id for null or not null  
 and
 map that way, but it doesn't look like  the polymorphic mapper can
 handle that. Ah well.




 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Rick Morrison

Dude, you should be WRITING them!

On 1/25/07, Michael Bayer [EMAIL PROTECTED] wrote:

 COALESCEwow i need to read some SQL books again... :)

 On Jan 25, 2007, at 11:17 AM, Rick Morrison wrote:

 
  You could do this in a single join using COALESCE on the fallback
  columns.
 
  Rick
 
  On 1/25/07, Karl Guertin [EMAIL PROTECTED] wrote:
 
  On 1/25/07, Christopher Arndt [EMAIL PROTECTED] wrote:
  It doesn't need to be recursive, just a two-level parent-child
  relation. And I
  don't want to add any columns, so I was thinking that table
  inheritance is not
  the right approach, but I'm not sure about that.
 
  I was thinking that you could check parent_id for null or not null
  and
  map that way, but it doesn't look like  the polymorphic mapper can
  handle that. Ah well.
 
 
 
 
  


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: post-populate extension

2007-01-25 Thread Rick Morrison

Ya, the post_populate hook w/b great -- getting the callback to work
was kinda tricky, and I'm worried calling back to internals like that.
Calling signatures often change on internals.

On 1/25/07, Michael Bayer [EMAIL PROTECTED] wrote:

 yup that would be how you can do that right now.

 i mean, I had this vision of SA being used inside of frameworks which
 would provide their own hooks for these kinds of things, i.e. post-
 query etc.  which is why i dont like to add too many hooks *inside*
 unless absolutely necessary.

 but yah if populate_instance() is doing it for you I dont see
 anything wrong with that(did you want a post_populate_instance()
 hook or something like that ?)

 On Jan 24, 2007, at 11:07 PM, Rick Morrison wrote:

 
  What's the best way to perfom a bit of manipulation on a mapper-loaded
  instance just AFTER it's been populated?
 
  Right now I'm using a mapper extension to override populate_instance
  and then calling back to the mapper argument to do the actual
  population, then adding my changes, but is that the best way?
 
  Thx,
  Rick
 
  


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: class-object-like attribute lookup

2007-01-25 Thread Michael Bayer


On Jan 25, 2007, at 9:35 AM, Christopher Arndt wrote:

 As you can see 'parent_id' is a self-referencing FK to the  
 bookmarks table. The
 idea now is to allow users to have their own copies of mapped  
 'Bookmark'
 objects, that are a sort of child of an existing 'Bookmark' object  
 and allow
 them to overwrite certain columns like e.g. 'title' and  
 'description'. But if
 the column is NULL, it should be looked up in the parent object/ 
 row. Sort-of
 like in class/object attributes in Python classes.

i almost understand what you mean, but what column is NULL?  if the  
parent_id column is null, then youre the topmost parent bookmark  
(i.e. no parent to be looked up).  if the owner_id column is null,  
no user points to this bookmark.

it sounds like basically many users would point to a common record in  
the bookmark table, and for those users who want to override  
certain attributes, a new copy of that bookmark object is made for  
them and a new record with their owner_id gets inserted into the  
database.  is that it ?

ohyou mean, yes, they have their local bookmark copy, but if an  
attribute is NULL, it goes up to the parent.  right:

class Bookmark(object):
 def _get_inherited_attr(self, key):
 if getattr(self, _ + key) is None:
 if self.parent is not None:
 return getattr(self.parent, _ + key)
 return None
 title = property(lambda self:self._get_inherited_attr(title),  
lambda self, value:self._title=value)
 description = property(lambda self:self._get_inherited_attr 
(description), lambda self, value:self._description=value)
 url = property(lambda self:self._get_inherited_attr(url),  
lambda self, value:self._url=value)

mapper(Bookmark, bookmark_table, properties={
'parent':relation(Bookmark, remote_side=bookmark_table.c.id),
'_title':bookmark_table.c.title,
'_description':bookmark_table.c.description,
'_url':bookmark_table.c.url
})

the above can be made more concise by creating your own property  
class, i.e. a class that has __get__() and __set__() methods, instead  
of using the property() function.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: post-populate extension

2007-01-25 Thread Michael Bayer

ok show me how youre doing it and ill see if i should make something  
more solid for that.

On Jan 25, 2007, at 11:52 AM, Rick Morrison wrote:


 Ya, the post_populate hook w/b great -- getting the callback to work
 was kinda tricky, and I'm worried calling back to internals like that.
 Calling signatures often change on internals.

 On 1/25/07, Michael Bayer [EMAIL PROTECTED] wrote:

 yup that would be how you can do that right now.

 i mean, I had this vision of SA being used inside of frameworks which
 would provide their own hooks for these kinds of things, i.e. post-
 query etc.  which is why i dont like to add too many hooks *inside*
 unless absolutely necessary.

 but yah if populate_instance() is doing it for you I dont see
 anything wrong with that(did you want a post_populate_instance()
 hook or something like that ?)

 On Jan 24, 2007, at 11:07 PM, Rick Morrison wrote:


 What's the best way to perfom a bit of manipulation on a mapper- 
 loaded
 instance just AFTER it's been populated?

 Right now I'm using a mapper extension to override populate_instance
 and then calling back to the mapper argument to do the actual
 population, then adding my changes, but is that the best way?

 Thx,
 Rick







 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: mapped classes and (Oracle) CLOB's?

2007-01-25 Thread Michael Bayer

we just implemented our very first oracle BLOB support in 0.3.4.   
havent tested CLOBs yet...this may require an explciit type in the  
oracle module along the same lines as OracleBinary (i.e. OracleText,  
or OracleCLOB perhaps).  one thing I can say though, cx_oracle's  
support for LOBs is extremely limited and more enhanceents to SA to  
make them usable are needed (such as better result-set support for  
active rows).  check out the CHANGES file on the site for some notes  
on it.


On Jan 25, 2007, at 12:12 PM, Bryson Lee wrote:


 Is there a canonical way to deal with class data members that map to
 CLOB fields in the database?  When I map to Oracle tables containing
 CLOB's, I get an exception from cx_Oracle about the LOB-locator object
 being invalidated by a subsequent fetch when I reference the CLOB
 member of the mapped class in code.

 What I think needs to happen is that when the class member is created,
 instead of making it refer to the cx_Oracle LOB-locator itself the
 member should be set to the result of locator.read().

 Is this something that'd have to be patched into the engine/driver, or
 can I handle it in a mapper extension?

 I'm using SA 0.3.1 at the moment -- might there be better CLOB support
 in 0.3.4?

 Thanks,

 Bryson


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: post-populate extension

2007-01-25 Thread Rick Morrison

K, here's a snipppet that shows the populate_instance catch. It's
pretty straightforward, but the way that the hook takes (row,
instance) in that order, while the callback to the mapper takes
(instance, row)  got me thinking about calling back to internals and
API stability.


def populate_instance(self, mapper, selectcontext, row, instance,
identitykey, isnew):
if isnew:
mapper.populate_instance(selectcontext, instance, row,
identitykey, isnew)
instance.onload()
return None
return EXT_PASS

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] pool echo

2007-01-25 Thread Jonathan Ellis
Minor question: wouldn't it be more consistent to either apply echo to
all pool logging, or get rid of it and let logger settings control it?
 Here's a patch for the former.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



pool.patch
Description: Binary data


[sqlalchemy] Re: any particular reason for creating unused lists?

2007-01-25 Thread Jonathan Ellis

Reasonable people can differ here, but I agree that if what you care
about is a side effect, rather than a resulting list, using a for loop
is more clear than a list comprehension.  (I suspect it is also more
performant since you are not allocating and populating a list object
for no reason.)

But in this case I think it's clear that the best way is to simply write

t.extend(data)


On 1/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 there are several places of such unused lists being made.

 i pick a random occurence, in this case InstrumentedAttribute:

 def _adapt_list(self, data):
 if self.typecallable is not None:
 t = self.typecallable()
 if data is not None:
 [t.append(x) for x in data]
 return t
 else:
 return data

 why not just
 for x in data: t.append(x)


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: any particular reason for creating unused lists?

2007-01-25 Thread Michael Bayer

just habit ...i dont like one liners with :, also makes it easy to
tack on conditionals...feel free to submit a patch for all those if
theyre really bothering you (i guarantee program speed /mem usage will
not budge in any measurable way).

On Jan 25, 4:30 pm, [EMAIL PROTECTED] wrote:
 there are several places of such unused lists being made.

 i pick a random occurence, in this case InstrumentedAttribute:

 def _adapt_list(self, data):
 if self.typecallable is not None:
 t = self.typecallable()
 if data is not None:
 [t.append(x) for x in data]
 return t
 else:
 return data
 
 why not just
 for x in data: t.append(x)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: is pool supposed to be able to handle its target db restarting?

2007-01-25 Thread Jonathan Ellis

I'm restarting it after the first fetchall() finishes.

My experience with postgresql/psycopg2 is that you can tell the
connection is dead when you next try to call cursor(), but that isn't
happening here because of the queue problem I described.

Here's the output with pool logging on, if that helps:

 e = create_engine('postgres://[EMAIL PROTECTED]/mozy', pool_size=1,
max_overflow=0, pool_timeout=None, echo=True)
 e.execute('select 1').fetchall()
 2007-01-25 15:03:10,704 INFO sqlalchemy.pool.QueuePool.0x..b4
Created new connection connection object at 0xb79ca020; dsn:
'dbname=mozy host=db user=neptune', closed: 0
INFO:sqlalchemy.pool.QueuePool.0x..b4:Created new connection
connection object at 0xb79ca020; dsn: 'dbname=mozy host=db
user=neptune', closed: 0
2007-01-25 15:03:10,704 INFO sqlalchemy.pool.QueuePool.0x..b4
Connection connection object at 0xb79ca020; dsn: 'dbname=mozy host=db
user=neptune', closed: 0 checked out from pool
INFO:sqlalchemy.pool.QueuePool.0x..b4:Connection connection object at
0xb79ca020; dsn: 'dbname=mozy host=db user=neptune', closed: 0
checked out from pool
2007-01-25 15:03:10,705 INFO sqlalchemy.engine.base.Engine.0x..14 select 1
INFO:sqlalchemy.engine.base.Engine.0x..14:select 1
2007-01-25 15:03:10,705 INFO sqlalchemy.engine.base.Engine.0x..14 None
INFO:sqlalchemy.engine.base.Engine.0x..14:None
2007-01-25 15:03:10,709 INFO sqlalchemy.pool.QueuePool.0x..b4
Connection connection object at 0xb79ca020; dsn: 'dbname=mozy host=db
user=neptune', closed: 0 being returned to pool
INFO:sqlalchemy.pool.QueuePool.0x..b4:Connection connection object at
0xb79ca020; dsn: 'dbname=mozy host=db user=neptune', closed: 0 being
returned to pool
[(1,)]
# [db restarted]
 e.execute('select 1').fetchall()
2007-01-25 15:03:30,690 INFO sqlalchemy.pool.QueuePool.0x..b4
Connection connection object at 0xb79ca020; dsn: 'dbname=mozy host=db
user=neptune', closed: 0 checked out from pool
INFO:sqlalchemy.pool.QueuePool.0x..b4:Connection connection object at
0xb79ca020; dsn: 'dbname=mozy host=db user=neptune', closed: 0
checked out from pool
2007-01-25 15:03:30,691 INFO sqlalchemy.engine.base.Engine.0x..14 select 1
INFO:sqlalchemy.engine.base.Engine.0x..14:select 1
2007-01-25 15:03:30,691 INFO sqlalchemy.engine.base.Engine.0x..14 None
INFO:sqlalchemy.engine.base.Engine.0x..14:None
Traceback (most recent call last):
  File stdin, line 1, in ?
  File /root/SQLAlchemy-0.3.4/lib/sqlalchemy/engine/base.py, line
686, in fetchall
for row in self.cursor.fetchall():
psycopg2.ProgrammingError: no results to fetch
 e.execute('select 1').fetchall()
# [hangs]

On 1/25/07, Michael Bayer [EMAIL PROTECTED] wrote:

 if you close all connections (i.e. return them all to the pool), and
 then go to get them again, it can handle a restart *if* the dialect
 knows how to detect the conditions whereby it should invalidate() the
 connections.  which is generally pretty spotty, i dont think PG knows
 how to do it.  also i dont understand the error condition you are
 getting, the connections should all be getting returned above ( or some
 exception would be thrown).

 are you stopping the DB while the first fetchall() is executing ?  or
 in between ?


 On Jan 25, 3:54 pm, Jonathan Ellis [EMAIL PROTECTED] wrote:
  from sqlalchemy import *
  e = create_engine('postgres://...', pool_size=1, max_overflow=0,
  pool_timeout=None)
  e.execute('select 1').fetchall()
  # restart db
  e.execute('select 1').fetchall()
  # error gets raised, ConnectionRecord apparently doesn't get returned
  to pool because:
  e.execute('select 1').fetchall()
  # hangs, pool overflow=1 (so new CR is not created) but nothing is in the 
  queue


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] some failures on polymorphic-mapper with non-lazy relations

2007-01-25 Thread sdobrev
i have added a switch for lazy on/off to that 115-case full 
combination test for A-B inheritance and relations.
For lazy=True all is ok.
For lazy=False, i am setting lazy=False only for those relations which 
refer to klas not a subklas to the main one.
The result is 8 cases fail, all of same pattern, and with same error 
(keyerror on discriminator being None):

$ python sa_ref_A_B_A_all.py no_lazy 

-- fail: 8 of total 115 ; 6 %
poly=   1, inh=tableinh, Alink=   B, Blink=   A, BAlink=None :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=   B, Blink=   A, BAlink=   B :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=   B, Blink=  A1, BAlink=None :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=   B, Blink=  A1, BAlink=   B :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=  B1, Blink=   A, BAlink=None :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=  B1, Blink=   A, BAlink=  B1 :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=  B1, Blink=  A1, BAlink=None :::
  KeyError:  ssingle A
poly=   1, inh=tableinh, Alink=  B1, Blink=  A1, BAlink=  B1 :::
  KeyError:  ssingle A

i've picked 1st testcase.

All can be generated via 
 $ python sa_ref_A_B_A_all.py no_lazy generate_many

ciao
svil

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



sa_gentestbase.py
Description: application/python


sa_B_inh_A_A_ref_AB.py
Description: application/python


sa_generator.py
Description: application/python


_test_AB_poly_1__inh_tableinh__Alink_B__Blink_A__BAlink_None.py
Description: application/python


[sqlalchemy] Re: some failures on polymorphic-mapper with non-lazy relations

2007-01-25 Thread Michael Bayer

self-referential eager loads are never going to be supported.  the bug
here is that the eager loader isnt checking hard enough to see that its
in fact self-referential.

On Jan 25, 6:12 pm, [EMAIL PROTECTED] wrote:
 i have added a switch for lazy on/off to that 115-case full
 combination test for A-B inheritance and relations.
 For lazy=True all is ok.
 For lazy=False, i am setting lazy=False only for those relations which
 refer to klas not a subklas to the main one.
 The result is 8 cases fail, all of same pattern, and with same error
 (keyerror on discriminator being None):

 $ python sa_ref_A_B_A_all.py no_lazy

 -- fail: 8 of total 115 ; 6 %
 poly=   1, inh=tableinh, Alink=   B, Blink=   A, BAlink=None :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=   B, Blink=   A, BAlink=   B :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=   B, Blink=  A1, BAlink=None :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=   B, Blink=  A1, BAlink=   B :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=  B1, Blink=   A, BAlink=None :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=  B1, Blink=   A, BAlink=  B1 :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=  B1, Blink=  A1, BAlink=None :::
   KeyError:  ssingle A
 poly=   1, inh=tableinh, Alink=  B1, Blink=  A1, BAlink=  B1 :::
   KeyError:  ssingle A

 i've picked 1st testcase.

 All can be generated via
  $ python sa_ref_A_B_A_all.py no_lazy generate_many

 ciao
 svil

  sa_gentestbase.py
 2KDownload

  sa_B_inh_A_A_ref_AB.py
 4KDownload

  sa_generator.py
 10KDownload

  _test_AB_poly_1__inh_tableinh__Alink_B__Blink_A__BAlink_None.py
 2KDownload


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Persistence Layer best practices with SQLAlchemy

2007-01-25 Thread Allen

I am evaluating SQLAlchemy for a new project we are starting up and it
looks great.  The only remaining question I have about it is if there
are some recommended best practices for using it as a agile-data style
persistence layer for application development.  (something like:
http://www.ambysoft.com/essays/persistenceLayer.html)

The basic idea of a persistence layer (as I understand it) is that you
attempt to isolate applications from the database to the point that the
application and the data model can vary independently without requiring
major code changes.  As the paper above puts it, a well build
persistence layer for an application should allow moving tables,
renaming tables, renaming columns, and reorganizing tables without
affecting the applications that access them.

I am not optimistic enough to think that any system is *that* good, but
it looks like someone could get quite a bit done towards that goal
using SQLAlchemy if they worked at it.

My current list of best practices to accomplish this goal includes:

   * explicitly set column names in the data mappers to avoid
dependencies on column names
   * keep all mappers and setup in one common module that you use
everywhere
   * use the sql construction language for all queries

As you can see, my list is quite short. :)

Does anyone have additional suggestions for someone just getting
started with SQLAlchemy?

Thanks,
Allen


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---