Hi,
I'm trying to debug some issues with sessions in my SQLAlchemy 0.7.4
application. However, setting echo_pool to True doesn't seem to log
anything to standard output:
db_engine=create_engine(DB_URI, echo_pool=True)
Session = sessionmaker(bind=db_engine)
Standard logging (echo=True) works
.
echo_pool=True just shows major events like connection invalidations.
On Jul 9, 2012, at 9:25 AM, bojanb wrote:
Hi,
I'm trying to debug some issues with sessions in my SQLAlchemy 0.7.4
application. However, setting echo_pool to True doesn't seem to log
anything to standard output:
db_engine
This can be done and it's not too complicated, but beware as in 95% of
the time it's a deficency in your model; ie. you can refactor your
model so that you don't need this.
If it's the other 5% of cases, here's what the code looks like (I
can't honestly remember if I read this in the docs or got
However, I have issues with the difference in NULL value semantics
between Python and SQL. Ie. if a calculated column is defined via a
column_property as price*amount, then the result will be NULL if any
of the values is NULL. However, in Python, None*something throws a
TypeError, so the
with a mix of Python
properties and column_properties.
On Jan 14, 4:23 pm, Michael Bayer mike...@zzzcomputing.com wrote:
bojanb wrote:
Let's say I want to have a simple calculated property in my class, eg.
amount which is just qty * price.
I can define it as a column_property in a mapper
Let's say I want to have a simple calculated property in my class, eg.
amount which is just qty * price.
I can define it as a column_property in a mapper which makes it
available in all database operations, eg. I can write session.query
(myclass).filter_by(amount1000) which will create the
This does it. One small drawback is that since the field is now
defined as an attribute, one can't query on it (ie. session.query
(class_).filter_by(modified_by='jack')), but we don't envison such a
use case for this funcionality so it's OK for us.
Recap of what was done: table columns were
What is the easiest way of getting the equivalent of this:
session.query(Someclass).filter_by(related_obj.field=somevalue)
Ie. I want to filter by a field of an object that is in relation to
objects of Someclass.
My original idea was to add related_obj.field as a new relation in the
mapper for
Hi,
Can I have identical column names in both parent and child classes
that are part of a joined-table inheritance? These are simply created,
created_by, modified, modified_by columns that are populated by
defaults defined for them (ie. default, server_default, onupdate).
The values are written
On Oct 29, 5:32 pm, Michael Bayer mike...@zzzcomputing.com wrote:
how would the UOW honor RESTRICT ? if you tell it to delete a parent,
and you didn't tell it to delete a child, and you have a non-nullable FK
or RESTRICT, you'd expect it tothrow an error, right ? isn't that
what
Yes, the passive_deletes='all' solves this, the trick is to put it in
the backref (I was putting it in the forward relation).
On Oct 29, 8:29 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Michael Bayer wrote:
bojanbwrote:
On Oct 29, 5:32 pm, Michael Bayer mike...@zzzcomputing.com
I have columns in my database that logically shouldn't be null.
However, I allow them to be null while the user is editing (creating)
objects interactively. As this is done in a transaction, and values
are checked before a commit, it's assured that nobody else ever sees
invalid values and the
explicitly in the application), but ondelete='RESTRICT' is not honored
in such a setup.
On Oct 26, 4:13 pm, Michael Bayer mike...@zzzcomputing.com wrote:
bojanb wrote:
I have columns in my database that logically shouldn't be null.
However, I allow them to be null while the user is editing (creating
I was under the impression that returning EXT_STOP in my
MapperExtension.before_insert() can prevent an object from being
inserted into the database altogether, but that doesn't seem to be
working, so I'm not sure if I'm misunderstanding the operation of
MapperExtensions or it's a bug.
I'd like
it does not.
http://www.sqlalchemy.org/docs/05/reference/orm/interfaces.html?highl...
Returning EXT_STOP will halt processing of further extensions handling
that method.
that only refers to additional extensions.
Right. The doc was a little ambigous - the or use the default
functionality
My issue with SQLA validators is that they don't allow inconsistent
state even on fields of a single object, which makes multi-field
validation impossible.
Eg. imagine you have fields tax_id and country_code on a customer
object. For country code 'us', tax_id should be 9 digits long; for
country
meaning, you set A.a and you can't depend on A.b being correct yet ?
Well sure. How would you have it done ? Something has to trigger the
validate event at some point. So if you need to wait for all of A.a,
A.b, A.c, etc. to be setup first, then sure you'd throw your validation
into
the solution is the same as that I illustrated in a previous email, that
when you map to a JOIN you must place all equivalent columns which you
would like populated identically in groups. This is described
athttp://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-agains...
You're
with_polymorphic can be set against any subset of classes, not just '*'.
Yes, but in the first case I can't use with_polymorphic() on the
query, because the query class is not the problem - I want the
polymorphic load on an attribute (relation) of the queried class in
order for the eagerload to
I don't have the time most of today to get into it so I can't confirm
what's going on. Any chance you could map to a straight join of all four
tables instead of a join to two sub-joins ?
I tried the following join in the mapper for Subordinate:
join(Employee, Person).join(Relation,
The problem is when I have an object mapped against two tables, both
of which are part of an inheritance hierarchy. I managed to
synchronize the foreign key with the primary key (per the
documentation link you provided). However, SQLAlchemy doesn't (or I
can't instruct it how to) set the
in the
same way.
On Sep 15, 4:32 pm, Michael Bayer mike...@zzzcomputing.com wrote:
bojanb wrote:
The problem is when I have an object mapped against two tables, both
of which are part of an inheritance hierarchy. I managed to
synchronize the foreign key with the primary key (per the
documentation
The root of the problem is inheritance. Let's say that I have a Person
class and an Employee class that inherits from it. I also have a
Meeting class that records meetings between two persons.
A query on Meeting will always lazy load Employee's attributes,
regardless of any lazy/eagerload
still don't know how to instantiate
objects of a class mapped against two tables when they contain both an
autogenerated primary key from the first table and a mandatory foreign
key from the second...
On Sep 14, 4:31 pm, Michael Bayer mike...@zzzcomputing.com wrote:
bojanb wrote:
The root
Here's something I've been struggling with recently. I'll include the
description of steps that got me here, as I believe the context will
make the question clearer.
It all started because I needed to show data (eg. in a list form) from
two related tables (classes). However, SQLAlchemy would
I'm not sure if this is a bug or I am just setting up the attribute
wrong. Anyways, I'm having a problem defining count-type SQL mapped
attribute in a situation with many-to-many relationships.
The example here uses the classic book-author many-to-many relation.
An author can have many books,
Hello,
It took me a couple of days to narrow this down. It appears that when
object inherits from another object via joined table inheritance (I
haven't tested the other two inheritance modes), mapped attributes
defined as SQL expressions don't load correctly.
In the example below I have a
27 matches
Mail list logo