On Fri, Mar 10, 2017 at 3:40 PM, mike bayer
wrote:
> If this is truly, "unexpected error but we need to do things", perhaps you
> can use before_flush() to memoize the details you need for a restore inside
> of session.info.
>
> An event hook can be added but it would
I have been looking for a way to know what's going to be rolled back in
SQLAlchemy so that I can know what was changed and restore other database
unrelated things to their previous state.
By http://docs.sqlalchemy.org/en/latest/orm/events.html#session-events it
looks like it's available an
Just noticed that SQLAlchemy 0.9 broke a LazyForeignKey class that was
provided by TurboGears tgext.pluggable to make possible to declare foreign
keys to models not yet defined at the time the ForeignKey was declared.
The main use was something like:
class User(DeclarativeBase):
Looks good, just one curiosity, is there a reason for using
after_parent_attach
event instead of directly using _set_parent to register the LazyForeignKey
for being resolved?
2014/1/13 Michael Bayer mike...@zzzcomputing.com
On Jan 13, 2014, at 1:19 PM, Alessandro Molina
alessandro.mol
Yes,I know, so simple... but it didn't work for me as far I didn't set the
label for the internal select.
I try it many times, but always without it; I didn't know it was mandatory.
Thank you.
first_id_row = s.query(Row.id_row).\
filter(Row.id_head ==
with MySql.
Thanks for your help
Alessandro
PS: I can get the same result with a different subquery, but I don't like
it because it seems to me more complex: a subquery get the max_row_id and
the min_row_id for each head_id, then I join it with HEAD, ROW as ROW_A and
ROW as ROW_B and I get
).all()
On internet I found old answers that say it is not possible, but it
was the far 2007.. :-)
Alessandro
--
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
On Mon, Feb 07, 2011 at 10:26:18AM -0500, Michael Bayer wrote:
Its easier to do in 0.7 where you just say
event.listen(MyObject.attribute, append, fn),
any time you want.Though we haven't implemented remove yet.
I'd wait for the 0.7 betas if possible.
nice!, but it's not an option to
On Mon, Feb 07, 2011 at 01:32:52PM -0500, Michael Bayer wrote:
Otherwise you can append your AttributeExtension into the listeners
collection on the attribute, I'd have to check the source of attributes.py
to recall the exact name of the collection.
a hint here would be appreciated.
Hi,
I have a join between 2 tables (User/Adresses, complete code below). I create a
mapper as
the join of the 2 classes as:
m = orm.mapper(Join, User.__table__.outerjoin(Address.__table__) ,
properties = {
'j_id' : [Address.__table__.c.user_id,
On Tue, Aug 24, 2010 at 02:48:37PM -0400, Michael Bayer wrote:
Info option is clearly very handy. At the moment I implemented an image
field in sqlkit, (that's just a bunch of handler in the gui). In order to do
that I used a type inherited with no addition, just to understand that that
Hi again, sorry for flooding with email this week...
I stumbled on the CircularDependencyError in some occasions with self
referencing models. I do understand that it can be tricky to INSERT and DELETE
but I'm just updating rows.
I reduced my problem to the bare minimum. It works both on 0.5.8
On Sat, Aug 21, 2010 at 01:45:48PM -0400, Michael Bayer wrote:
columns in a property
column = prop.columns[0]
props = []
for pr in mapper.iterate_properties:
if isinstance(pr, properties.RelationProperty):
if pr.direction.name in ('MANYTOONE',):
Hi,
I have been using session with autocommit=True and autoflush=False for a
while now. I'm pretty happy with this but now I find something that I
cannot understand: a session with dirty set full, after a begin() is
empty, but no update is issued. How can that be possible? (And yes!
Hi,
is there a way to set the type of a column added to a mapper with
column_property?
m = mapper(New, t, properties={
'my_bool': column_property(
func.my_bool(t.c.id, type=Boolean)
)
})
func 'my_bool' is a stored procedure on Postgresql and
On Fri, Dec 04, 2009 at 02:52:37PM -0500, Michael Bayer wrote:
On Dec 4, 2009, at 2:20 PM, Alessandro Dentella wrote:
On Fri, Dec 04, 2009 at 01:27:46PM -0500, Michael Bayer wrote:
On Dec 4, 2009, at 1:18 PM, Alessandro Dentella wrote:
Is the only solution to attach an instance
Hi,
docs suggests (Mapping a Class against Multiple Tables) to build a mapper
as this:
class AddressUser(object): pass
j = join(users_table, addresses_table)
mapper(AddressUser, j, properties={
'user_id': [users_table.c.user_id, addresses_table.c.user_id]
})
Is the only solution to attach an instance (u.job = myjob) or is there
another solution that doesn't require me to build the instance?
if you want SQLA's delete-orphan capability, that's the only way. If you
want to rely upon CASCADE rules in your DB to handle it instead, that's
On Fri, Dec 04, 2009 at 01:27:46PM -0500, Michael Bayer wrote:
On Dec 4, 2009, at 1:18 PM, Alessandro Dentella wrote:
Is the only solution to attach an instance (u.job = myjob) or is there
another solution that doesn't require me to build the instance?
if you want SQLA's delete
Hi,
I'm stuck with the code below raise FlushError complaining:
Traceback (most recent call last):
File stdin, line 49, in module
File /misc/src/sqlalchemy/sqlalchemy/lib/sqlalchemy/orm/session.py, line
673, in commit
self.transaction.commit()
File
Movie is attached to a Director or not. like the FAQ says, we choose
not to get into generating events from foreign keys being set.
which is not a forever rule, but if you look in trac there are about
300 ORM issues open that I'd rather get resolved before I have the
time to
On Thu, Jul 23, 2009 at 02:48:12PM -0400, Michael Bayer wrote:
add passive_deletes = True
Thanks and sorry for the noise on such trivial question, present in the
faq... , I've already used it and... forgot!
sandro
--~--~-~--~~~---~--~~
You received this
In faq 5.13 it's explained why setting bar.foo_id would not generate the
object bar.foo.
I stumble in the same problem when creating a Movie in an example with
Director/Movie and a relation -'movies' on director- that has
'delete-orphan'.
running::
f = m.Movie(title=my title)
[Sorry for reposting, Erroneously sent to another thread.]
In faq 5.13 it's explained why setting bar.foo_id would not generate the
object bar.foo.
I stumble in the same problem when creating a Movie in an example with
Director/Movie and a relation -'movies' on director- that has
On Sat, May 23, 2009 at 02:43:33PM -0400, Michael Bayer wrote:
On May 23, 2009, at 10:15 AM, Alessandro Dentella wrote:
Hi,
when from my pygtk application i commit, I really do::
if self.session.autocommit:
self.session.begin
Hi,
when from my pygtk application i commit, I really do::
if self.session.autocommit:
self.session.begin()
self.session.commit()
I'm normally using session.autocommit = True as a mean to prevent all
those 'idle in transaction' processes (that
Hi,
in a sessionExtension.after_flush hook I create objects (namely todo
actions depending on what people have inserted/updated).
At present I create these objects in the current session, but I do
understand is not clean as the flush has already occurred. It almost
works, objects are
Hi,
how should I configure a mapper that represents a join between two tables
so that inserting a new object writes the foreign key between the two in
the proper way?
class Table_a(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
Hi,
i'm playing with outerjoin defined in the mapper. I'm getting results
different from what I expected, so that I would like to understand which is
the underline logic.
Where a Query w/ outerjoin SELECT has in the backend n rows and would have m
rows in a simple join, I only get m rows plus
Hi,
I have a structure as this:
fossati
setup (module with attribute USER)
models/cliente(User)
calendar (Entry)
apps/job
in calendar.py:
from cliente import User
class Entry(Base):
...
user = relation(User,
Hi,
I have a definition similar to this::
class Ticket(Base):
__tablename__ = 'ticket'
id = Column(Integer, primary_key=True)
assigned_to_id = Column(ForeignKey(User.id))
assigned_to = relation(User, primaryjoin = assigned_to_id == User.id,
Hi,
is there a way to get the session an object belongs to?
I have been looking around and cannot find any function/way for that...
Thanks in advance
sandro
*:-)
--
Sandro Dentella *:-)
http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy
Hi,
I'd like to get programmatically the class to which a relation
points. Suppose I have the following situation:
class Project(Base):
...
staff = relation(User, secondary=project_manager)
manager = relation(User, secondary=project_staff)
Now I want to get User class
Hi,
i'm adding in sqlkit library some signals around commit, and particularly
in post-commit phase.
As I'd like to have the possibility to see which attributes where modified
from within the callback I used 'after_flush' method of SessionExtension.
So I have 2 questions:
1.
On Thu, Feb 19, 2009 at 12:57:07PM +0100, Alessandro Dentella wrote:
Hi,
in a working setup I added a ForeignKey to table 'cliente_cliente' as
follows (client_id):
class Project(Base):
__tablename__ = ticket_project
__table_args__ = {'useexisting' : True}
id
On Sun, Feb 01, 2009 at 04:41:11PM -0500, Michael Bayer wrote:
Here you go, its a psycopg2 bug. Familiarize yourself with the
attached test case, then post it on the psycopg2 mailing list.
Thanks a lot for you fast and valuable help, as usual. I verified that
version 2.0.8 of psycopg2 does
stack trace you posted doesn't make sense to me though, as its issuing
a SELECT statement but PG is raising an exception for an UPDATE /
DELETE ? I've never seen that before. If you can provide a self-
contained test case which reproduces that behavior we can try it out.
Here is is.
connection already closed is a psycopg2 error indicating that the
socket has been shut down. looking at your output, I see a raw
execute() occuring within the string conversion of your Project object
and theres a module called sqlkit/db/utils.py causing an exception
throw. SQLA's
On Wed, Jan 07, 2009 at 01:12:48PM -0500, Michael Trier wrote:
Hi
On Wed, Jan 7, 2009 at 9:35 AM, sandro dentella san...@e-den.it wrote:
I realize now that autoloading a float field in Sqlite returns a
SLNumeric rather that Float. The schema is:
is this a known issue?
in another place comparing str fails just because a join has ON join
condition inverted (but semantically equivalent). What's the correct
way to test if two queries are semantically equivalent?
Thanks
sandro
*:-)
Hi sandro, did you want to compare
On Tue, Nov 18, 2008 at 10:27:32AM -0500, Michael Bayer wrote:
is_modified() shouldn't trigger a flush. is that with rc4 ?
no it was svn rev. 4935. It's still the same with rev. 5311.
I verified again: autoflush=False, just works. Autoflush=True
shows that
## here session.new is not empty
On Tue, Nov 18, 2008 at 11:31:38AM -0500, Michael Bayer wrote:
is_modified() has a flag passive which when set to True, disables lazy
loaders from executing. As it turns out the flag was also not hooked up
so you'd have to use the latest trunk to get this.
the reason it wants to lazily
On Sat, Oct 11, 2008 at 11:19:31PM -0400, Michael Bayer wrote:
On Oct 11, 2008, at 1:44 PM, sandro dentella wrote:
Hi,
I started using the .join() method on query and that' s really
powerful, with reset_joinpoint and the list of attributes setting the
path of relations. Now
Yep:
m = sqlalchemy.orm.class_mapper(User)
Thanks a lot!
*:-)
--~--~-~--~~~---~--~~
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
44 matches
Mail list logo