Hi,
Have you checked the __iter__ method ?
-----Original Message-----
From: Christian Démolis <[email protected]>
Sender: [email protected]
Date: Tue, 31 Jan 2012 17:39:54
To: sqlalchemy<[email protected]>
Reply-To: [email protected]
Subject: [sqlalchemy] Overload Query Object
Hi Michael,
i overload class Query in my script.
i have 4 ways to obtain query's results.
1/ session.query(model.x).all()
2/ session.query(model.x).first()
3/ session.query(model.x).one()
4/ for e in session.query(model.x):
print e
in case 1,2,3, i know which method is used
What method is used in case 4 ?
Thanks in advance.
Chris
class Query(Query):
def __init__(self, *arg, **kw):
self._populate_existing = True
super(Query, self).__init__(*arg, **kw)
def all(self):
print "<all>", threading.current_thread()
param.lock_bdd.acquire()
global session
try:
x = super(Query, self).all()
except exc2.OperationalError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except exc2.StatementError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except:
raise
param.lock_bdd.release()
print "</all>", threading.current_thread()
return x
def one(self):
print "<one>", threading.current_thread()
param.lock_bdd.acquire()
global session
try:
x = super(Query, self).one()
except exc2.OperationalError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except exc2.StatementError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except:
raise
param.lock_bdd.release()
print "</one>", threading.current_thread()
return x
def first(self):
print "<first>", threading.current_thread()
param.lock_bdd.acquire()
global session
try:
x = super(Query, self).first()
except exc2.OperationalError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except exc2.StatementError:
import common
common.alerte("L'écriture a échoué. Retentez l'action", "Erreur
MySQL")
session.rollback()
except:
raise
param.lock_bdd.release()
print "</first>", threading.current_thread()
return x
--
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 protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
--
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 protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.