[sqlalchemy] Re: column_property() caching

2007-12-04 Thread Marco Mariani

Vladimir Iliev wrote:
 hi, is it possible to add a non-caching column_property() to my mapping?
   

You can use expire() on a single column, so you could proxy that column 
with a @property that also expires it.



-- 
This e-mail (and any attachment(s)) is strictly confidential and for use only 
by intended recipient(s).  Any use, distribution, reproduction or disclosure by 
any other person is strictly prohibited. The content of this e-mail does not 
constitute a commitment by the Company except where provided for in a written 
agreement between this e-mail addressee and the Company.
If you are not an intended recipient(s), please notify the sender promptly and 
destroy this message and its attachments without reading or saving it in any 
manner.
Any non authorized use of the content of this message constitutes a violation 
of the obligation to abstain from learning of the correspondence among other 
subjects, except for more serious offence, and exposes the person responsible 
to the relevant consequences.


--~--~-~--~~~---~--~~
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] column_property() caching

2007-12-04 Thread Vladimir Iliev

hi, is it possible to add a non-caching column_property() to my mapping?


--~--~-~--~~~---~--~~
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: column_property() caching

2007-12-04 Thread Michael Bayer

the easiest way to do this would be to issue the SQL yourself...below
uses the object_session() and object_mapper() functions to ensure that
the current connection, if any, is used (you could also just say
myengine.execute() if that didnt matter):


class MyClass(object):
   @property
   def someprop(self):
   return object_session(self).\
execute(select([MyClass.somecol]).where(MyClass.id==self.id),
\
mapper=object_mapper(self)).scalar()


--~--~-~--~~~---~--~~
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] orm overrides explicit value sets

2007-12-04 Thread Kapil Thangavelu
i've attached an example, where a class constructor setups a default value
on a relation field, in the constructor, the app code latter explicitly sets
the fk attribute on the class, but sa ignores this value, and in the
flushing process sets it be the value of the orm field, so that it
'magically' becomes none even though it was explicitly set, which throws an
integrity constraint violation since the fk is setup to be not null.
not sure if this a bug or just a warning on sa usage patterns..

cheers,

kapil

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---

from sqlalchemy import create_engine, MetaData, Table, Column, types, ForeignKey
from sqlalchemy.orm import mapper, session, relation

metadata = MetaData()
metadata.bind = create_engine('sqlite://')

model_table = Table(models,
metadata,
Column(id, types.Integer, primary_key=True),
Column(status_id, types.Integer, ForeignKey(statuses.id), nullable=False),
)

status_table = Table(statuses,
 metadata,
 Column(id, types.Integer, primary_key=True),
 Column(name, types.Unicode, unique=True )
 )

metadata.create_all()

class Model( object ):

def __init__( self, status=None):
self.status = None

class Status( object ): pass

mapper( Model, model_table,
properties = {
   'status': relation( Status, backref=models)
   }
)

mapper( Status, status_table )

status_table.insert( values=dict(id=1, name=u'production') ).execute()

s = session.Session()

m = Model()
m.status_id = 1

s.save(m)
# nice error .. integrity constraint violation,  message status_id is null magically
s.flush()
















[sqlalchemy] problem with cast in postgres

2007-12-04 Thread Glauco
Hi all, i'm using the funct.cast in postgreSQL, but i thing the correct 
dialect is not used


This is an example:
valore is a text field.



Scheda.select( tbl['scheda'].c.valore == '753' )

SELECT scheda.id_precedente AS scheda_id_precedente, scheda.stato_record 
AS scheda_stato_record, scheda.ts_ultima_modifica AS 
scheda_ts_ultima_modifica, scheda.cod_unita_di_misura AS 
scheda_cod_unita_di_misura, scheda.id_figura_aziendale AS 
scheda_id_figura_aziendale, scheda.id AS scheda_id, scheda.id_azienda AS 
scheda_id_azienda, scheda.partite AS scheda_partite, 
scheda.cod_caratteristica_rischio AS scheda_cod_caratteristica_rischio, 
scheda.cod_attivita AS scheda_cod_attivita, scheda.id_produzione AS 
scheda_id_produzione, scheda.data_rilevamento AS 
scheda_data_rilevamento, scheda.id_unita_aziendale AS 
scheda_id_unita_aziendale, scheda.id_operatore AS scheda_id_operatore, 
scheda.valore AS scheda_valore
FROM scheda
WHERE scheda.valore = %(scheda_valore)s ORDER BY scheda.id
{'scheda_valore': '753'}


Scheda.select( func.cast( tbl['scheda'].c.valore, 'int')  == '753' )

SQLError: (ProgrammingError) syntax error at or near , at character 751
 'SELECT scheda.id_precedente AS scheda_id_precedente, 
scheda.stato_record AS scheda_stato_record, scheda.ts_ultima_modifica AS 
scheda_ts_ultima_modifica, scheda.cod_unita_di_misura AS 
scheda_cod_unita_di_misura, scheda.id_figura_aziendale AS 
scheda_id_figura_aziendale, scheda.id AS scheda_id, scheda.id_azienda AS 
scheda_id_azienda, scheda.partite AS scheda_partite, 
scheda.cod_caratteristica_rischio AS scheda_cod_caratteristica_rischio, 
scheda.cod_attivita AS scheda_cod_attivita, scheda.id_produzione AS 
scheda_id_produzione, scheda.data_rilevamento AS 
scheda_data_rilevamento, scheda.id_unita_aziendale AS 
scheda_id_unita_aziendale, scheda.id_operatore AS scheda_id_operatore, 
scheda.valore AS scheda_valore \nFROM scheda \nWHERE 
*cast(scheda.valore, %(cast)s)* = %(cast_1)s ORDER BY scheda.id' 
{'cast': 'int', 'cast_1': '753'}



casting in Postgres  use another syntax:
*cast(sche3086.valore as int)*

is this a bug or i'm missing to tell dialect?




Glauco

-- 



++
 Glauco Uri  
 glauco(at)sferacarta.com 
   
  Sfera Carta Software®   info(at)sferacarta.com
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054
++



--~--~-~--~~~---~--~~
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: problem with cast in postgres

2007-12-04 Thread Michael Bayer

CAST is its own contstruct:

Scheda.select( cast( tbl['scheda'].c.valore, 'int')  == '753' )



--~--~-~--~~~---~--~~
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: problem with cast in postgres

2007-12-04 Thread Glauco

Michael Bayer ha scritto:
 CAST is its own contstruct:

 Scheda.select( cast( tbl['scheda'].c.valore, 'int')  == '753' )
   


what doses it means?


ahhh ops !

i've get  cast from sqlalchemy.funct instead of sqlalchemy.sql

anyway  'int' cannot work
this is the proper use.

Scheda.select( sqlalchemy.sql.cast( tbl['scheda'].c.valore, 
sqlalchemy.types.INT)  == '753' )




Thank you Michael

-- 
++
 Glauco Uri  
 glauco(at)sferacarta.com 
   
  Sfera Carta Software®   info(at)sferacarta.com
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054
++



--~--~-~--~~~---~--~~
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: orm overrides explicit value sets

2007-12-04 Thread Michael Bayer


On Dec 4, 2007, at 12:34 PM, Kapil Thangavelu wrote:

 i've attached an example, where a class constructor setups a default  
 value on a relation field, in the constructor, the app code latter  
 explicitly sets the fk attribute on the class, but sa ignores this  
 value, and in the flushing process sets it be the value of the orm  
 field, so that it 'magically' becomes none even though it was  
 explicitly set, which throws an integrity constraint violation since  
 the fk is setup to be not null.

 not sure if this a bug or just a warning on sa usage patterns..


its the self.status =None.  its a contradiction for you to explicitly  
set status to None yet have the status_id set to a value.  if you  
leave self.status alone, the status_id will remain set.   i dont think  
this is particularly magical, its the relation() that you've  
explicitly created just doing its job.

you can also expire the 'status' attribute via s.expire(m, ['status'])  
which will prevent the value from affecting the flush.

its possible that sqlalchemy could look at the status_id attribute and  
see that it was modified, therefore leaving it alone, but this would  
allow contradicting attribute values which definitely would lead to  
deeper issues.  i would almost think that if you change both status  
and status_id in an incompatible way it should raise an error.

--~--~-~--~~~---~--~~
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] Representation of boolean logic in a database

2007-12-04 Thread Alexandre Conrad

hi,

this is more a database design question than a SA one.

I have 2 tables, clients and options. A client can subscribe to 
multiple options, and options can be subscribed by multiple clients 
(many-to-many). Of course, we have a weak table for the many-to-many 
relationship.

Then we have a 3rd table, contents. A content item is related to 
options, but through boolean logic operators: OR, AND, NOT.

My problem is beeing able to represent and store relations between 
options and contents tables in a normalized way.

Say,
content A is destinated subscribers of option A,
content B for subscribers of option B,
content A_and_B for subscribers of option A and option B,
content A_or_B for subscribers of option A or option B,
content A_and_not_B for subscribers of option A and must not be 
subscribed to B,
content A_or_not_B for subscribers of option A or the ones not 
subscribed to option B if not already subscribed to option A,
content not_A_or_not_B for subscribers that neither have option A or 
option B.

I don't need nested logic, like: option A and (option B or option C).

Neither do I need to mix AND and OR. Although, each of them needs to 
be mixed with NOT.

This is pretty much mind twising. But maybe this has already been 
standardized somehow. Any idea how this can be achieved ?

Regards,
-- 
Alexandre CONRAD


--~--~-~--~~~---~--~~
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] should a dns error return true in dialect.is_disconnect() ?

2007-12-04 Thread David Bonner

Hi, I've run into a problem running SA 0.4.0 on top of psycopg2.  We
had a DNS hiccup, and the next attempt to execute a query triggered a
ProgrammingError.  Unfortunately, it seems that error didn't also
invalidate the (implicit) connection, which was then returned to the
pool.

Successive queries returned a couple different errors (I can track
down the exact sequence of errors if you need it) but eventually we
end up getting InvalidRequestError(This connection is closed) every
time we run a query.  The backtrace looks something like:

2007-12-04 08:10:10,585 ERRORStorageWatcher-/build/storage-test/
release-Thread-2 - Unable to retrieve the list of builds on /build/
storage-test/release: This connection is closed
Traceback (most recent call last):
  File /mts-cm/home/dbonner/clients/storagetest/bin/
storagemanager.py, line 844, in getBuildList
builds = sess.query(Build).order_by(Build.buildid)\
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/orm/query.py, line
571, in all
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/orm/query.py, line
619, in __iter__
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/orm/query.py, line
622, in _execute_and_instances
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/orm/session.py, line
527, in execute
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py, line
779, in execute
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py, line
829, in _execute_clauseelement
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py, line
838, in _execute_compiled
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py, line
846, in __create_execution_context
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/databases/postgres.py,
line 303, in create_execution_context
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/default.py,
line 157, in __init__
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/databases/postgres.py,
line 255, in create_cursor
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/pool.py, line 338, in
cursor
  File /local/toolchain/lin32/python-2.4.3/lib/python2.4/site-
packages/SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/pool.py, line 327, in
invalidate
InvalidRequestError: This connection is closed


I poked around a little, and I'm guessing one fix might be to change
databases.postgres.PGDialect.is_disconnect() to treat the initial
ProgrammingError with no route to host in it as a disconnect error.
I just wanted to check and see if that was the right way to fix this
before I tried filing a trac ticket and submitting a patch.

Please let me know if I'm missing any useful details.  Thanks.
--~--~-~--~~~---~--~~
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: should a dns error return true in dialect.is_disconnect() ?

2007-12-04 Thread Michael Bayer


On Dec 4, 2007, at 3:26 PM, David Bonner wrote:


 Hi, I've run into a problem running SA 0.4.0 on top of psycopg2.  We
 had a DNS hiccup, and the next attempt to execute a query triggered a
 ProgrammingError.  Unfortunately, it seems that error didn't also
 invalidate the (implicit) connection, which was then returned to the
 pool.

 Successive queries returned a couple different errors (I can track
 down the exact sequence of errors if you need it) but eventually we
 end up getting InvalidRequestError(This connection is closed) every
 time we run a query.  The backtrace looks something like:

if the error message isnt caught by is_disconnect(), then yes the  
specific error message should be installed in there.  But also note  
that psycopg2 has some specific issues with disconnects, namely that  
the exception is not always raised cleanly..i had discussed this on  
the psycopg2 list and supplied test scripts illustrating the issue but  
i dont know if anyone took the time to verify what i was  
illustrating.  by not clean i mean the exception would get thrown in  
an asynchronous fashion so that we really couldnt catch it at all.   
ive seen tickets in psycopg2's trac which seem to address related  
issues.

but also, that you were getting this connection is closed would  
indicate that a recycle did occur, although if you have pool logs that  
would describe it more clearly.  But i wonder if you had long running  
Connection objects opened; at the moment, the Connection itself doesnt  
get a hold of a new DBAPI connection when a recycle occurs, youd have  
to open a new Connection.  Ive been meaning to change this behavior in  
trunk so that even holding open Connection would still allow a new  
recycle to happen.  Just curious how you configured on that end.


--~--~-~--~~~---~--~~
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] Collection class using OrderedDict and MappedCollection

2007-12-04 Thread Ronald Lew

I am creating a Collection class using the OrderedDict and
MappedCollection with primary key id as the key index.  The problem,
as noted in the docs, is that the key should be an immutable field.
Since I am using a primary key, the value will change when I am
instantiating a new object and adding it to the collection.  The code
illustrates my concept:

class Collection(OrderedDict, MappedCollection):
   def __init__(self, *args, **kwargs):
  MappedCollection.__init__(self, keyfunc=lambda item: item.id)
  OrderedDict.__init__(self, *args, **kwargs)

def refresh(self, *args, **kwargs):
 Updates all keys based on the keyfunc and each current
value
dict_copy = self.copy()
self.clear()
for item in dict_copy.values():
MappedCollection.set(self, item)


class Parent(Base): pass

class Child(Base): pass

session.mapper(class_=Child, local_table=child_table)

session.mapper(class_=Parent, local_table=parent_table,
   properties={'childs':relation(Child, backref='parent',
collection_class=ChildCollection)})


some_collection = ChildCollection()
new_child = Child(id=None, data='foo')
some_collection.set(new_child) # key is None, id is None

session.save(some_collection.values()) # save the child

# at this point, key is still None, but id is 1

some_collection.refresh() # key will be 1.
# I would like the refresh behavior to be invoked during/after a
flush.


Now, if I saved the Child under the Parent, then the key index would
have been updated automatically like so:
my_parent = Parent
Parent.childs.set(new_child)
session.save(Parent)
# The childs index will be 1
--~--~-~--~~~---~--~~
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: should a dns error return true in dialect.is_disconnect() ?

2007-12-04 Thread David Bonner


On Dec 4, 4:32 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 if the error message isnt caught by is_disconnect(), then yes the
 specific error message should be installed in there.  But also note
 that psycopg2 has some specific issues with disconnects, namely that
 the exception is not always raised cleanly..i had discussed this on
 the psycopg2 list and supplied test scripts illustrating the issue but
 i dont know if anyone took the time to verify what i was
 illustrating.  by not clean i mean the exception would get thrown in
 an asynchronous fashion so that we really couldnt catch it at all.
 ive seen tickets in psycopg2's trac which seem to address related
 issues.

yeah, the more i think about it, the more i realize this is an error
when the dbapi connection is created, it's not a disconnect
condition.  the original error message is No route to host, which
I'm pretty sure is EHOSTUNREACH, which you get on a socket connect,
not on a send.  which means that yep, this is likely an async
problem...the connection seems to be fine when you create it, but when
you use it, it throws the connection error.

 but also, that you were getting this connection is closed would
 indicate that a recycle did occur, although if you have pool logs that
 would describe it more clearly.  But i wonder if you had long running
 Connection objects opened; at the moment, the Connection itself doesnt
 get a hold of a new DBAPI connection when a recycle occurs, youd have
 to open a new Connection.  Ive been meaning to change this behavior in
 trunk so that even holding open Connection would still allow a new
 recycle to happen.  Just curious how you configured on that end.

it's a long-running multi-threaded daemon process, using a TLEngine
and all implicit connections.  the lifespan of the sessions are pretty
short, so i've assumed my threads weren't holding an open connection
object.  haven't configured pool logging to test it yet, though.
suppose it's a good time to learn how to do that in 0.4 now.
--~--~-~--~~~---~--~~
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: should a dns error return true in dialect.is_disconnect() ?

2007-12-04 Thread Michael Bayer


On Dec 4, 2007, at 5:39 PM, David Bonner wrote:



 yeah, the more i think about it, the more i realize this is an error
 when the dbapi connection is created, it's not a disconnect
 condition.  the original error message is No route to host, which
 I'm pretty sure is EHOSTUNREACH, which you get on a socket connect,
 not on a send.  which means that yep, this is likely an async
 problem...the connection seems to be fine when you create it, but when
 you use it, it throws the connection error.

oh it was much weirder than that.  we already do detect the  
disconnect on usage, so thats not an issue.  the issue was literally:

try:
cursor.execute(some sql)
except:
detect_disconnect_and_invalidate()
do_something()
do_something_else()

the cursor.execute would *not* raise an error.  then, the program  
fails, and the stack trace would say:

OperationalError: disconnect message  at do_something_else() line 52

meaning, the stack trace originated from an *arbitrary spot* in the  
application ! you could actually control it like this:

try:
cursor.execute(some sql)
time.sleep(5)
except:
detect_disconnect_and_invalidate()
do_something()
do_something_else()

the time.sleep() would change the point of exception to be within the  
try/except block !  the ticket is here:  
http://www.initd.org/tracker/psycopg/ticket/183 
   and the second email in the thread has the test script.  federico  
sort of thought it was a bug although i didnt follow his reasoning,  
but the ticket seems pretty dead.



--~--~-~--~~~---~--~~
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: should a dns error return true in dialect.is_disconnect() ?

2007-12-04 Thread Michael Bayer

ah, seems to be OK using python 2.5  and psycopg2.0.6, so, i guess  
thats fixed somehow

On Dec 4, 2007, at 5:59 PM, Michael Bayer wrote:



 On Dec 4, 2007, at 5:39 PM, David Bonner wrote:



 yeah, the more i think about it, the more i realize this is an error
 when the dbapi connection is created, it's not a disconnect
 condition.  the original error message is No route to host, which
 I'm pretty sure is EHOSTUNREACH, which you get on a socket connect,
 not on a send.  which means that yep, this is likely an async
 problem...the connection seems to be fine when you create it, but  
 when
 you use it, it throws the connection error.

 oh it was much weirder than that.  we already do detect the
 disconnect on usage, so thats not an issue.  the issue was  
 literally:

 try:
   cursor.execute(some sql)
 except:
   detect_disconnect_and_invalidate()
 do_something()
 do_something_else()

 the cursor.execute would *not* raise an error.  then, the program
 fails, and the stack trace would say:

 OperationalError: disconnect message  at do_something_else() line 52

 meaning, the stack trace originated from an *arbitrary spot* in the
 application ! you could actually control it like this:

 try:
   cursor.execute(some sql)
   time.sleep(5)
 except:
   detect_disconnect_and_invalidate()
 do_something()
 do_something_else()

 the time.sleep() would change the point of exception to be within the
 try/except block !  the ticket is here:  
 http://www.initd.org/tracker/psycopg/ticket/183
   and the second email in the thread has the test script.  federico
 sort of thought it was a bug although i didnt follow his reasoning,
 but the ticket seems pretty dead.



 


--~--~-~--~~~---~--~~
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] migration deprecation?

2007-12-04 Thread alex bodnaru

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


hi friends,

i was using the table.c.keys() to enumerate the fields of a table. what
would be the 0.4 way to do it?

thanks in advance,

alex
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBR1YBe9pwN1sq38njAQL2rgQApP6SW0rI5k9Nn/TvYzq3da7WawHdklwl
mV4eDvzl9WB3r61g35DrdlAzgOr1uxQMsAvgS3ZDpzYjmP0/1xx/Hw2RUn97IbHH
p3b4ljz3Flp8K4h1x5fl95giI2CyqyI0uzn3fdFCHWpU4ZIoSps9REP0LtWdWfJV
GE7wldimiXo=
=CAkQ
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---