Thanks for the very detailed explanation :) I think I'll tweak the
application flow to avoid this kind of thing altogether... Many thanks
again!
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving
and save
par.children = [child_reloaded]
session.add(par)
I tested this on SQLalchemy 0.9.4:
Traceback (most recent call last):
File testsa.py, line 44, in module
session.add(par)
File /home/joril/src/newprg/branches/sqla09/sqlalchemy/orm/session.py,
line 1478, in add
self
On Friday, April 26, 2013 12:25:42 AM UTC+2, Michael Bayer wrote:
this will work out of the box in 0.8 as auto-correlation has been improved
a lot. in 0.7 you can add correlate() explicitly:
Nice, many thanks :)
--
You received this message because you are subscribed to the Google
Hi everyone!
I have this working query:
select *
from A join B on A.id = B.a_id
where exists (select 1 from C where A.id = C.a_id and C.value B.value)
and I tried to implement it like this:
q = Session.query(entities.A)
q = q.join((entities.B, entities.A.id == entities.B.a_id))
q =
Hi everyone!
I'm trying to do a two-phase commit using SQLalchemy 0.6.8 with
Postgresql 8.3.4, but I think I'm missing something...
The workflow goes like this:
session = sessionmaker(engine)(autocommit=True)
tx = session.connection().begin_twophase(xid) # Doesn't issue any SQL
session.begin() #
On Jan 30, 5:02 pm, Michael Bayer mike...@zzzcomputing.com wrote:
What's happening above is the session is not in a transaction due to
autocommit, so when you call session.connection(), that connection is thrown
away as far as the Session is concerned. If you wanted to do it the
external
An entirely new database connection can resume this transaction by again
calling BEGIN PREPARED with the same XID.
I'm sorry, but I can't find this command inside the Postgresql docs... Am I
missing something?
I'm trying to do a multi-request two-phase transaction too, so I thought I
So I guess the idea is that each web request does a new PREPARE
TRANSACTION with a unique xid, then when the results of all those requests
are ready to be committed, the final call then calls COMMIT PREPARED
on the full list of xids.
I see... Many thanks for your timely explanation :)
Hi everyone!
Is it possible to have a many-to-one declarative relation between two
classes and a _filtered_ backref?
I'm trying to build a tagging system for my bloglike application, and
to allow a user to apply private tags to posts of other people. My
classes are:
Owner
Post
TagAssociation
Tag
On 7 Mar, 15:55, Michael Bayer mike...@zzzcomputing.com wrote:
the left outer join means there is a lazy=False or lazy='joinedload' on the
relationship, or in this case since its sporadic, the parent Invoice is
likely being loaded with an option like joinedload(Product.vat). The
options
Hi everyone!
I have an object graph like this:
Invoice - Detail (one-to-many with cascade) - Product (many-to-one) -
VAT (many-to-one)
My problem is that sometimes if I have a Detail and try to read its
Product, the triggered lazy-loading generates a query more complicated
than necessary,
Hi everyone!
I have a client-server application that communicates like this: the
client asks for something, the server fetches the data using
SQLAlchemy, serializes it and sends it back to the client. Now the
client can modify the data and send it back to the server for
persistence. It works
On Jan 22, 7:01 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Assuming the above raises its error just fine as it does on my system, there
must be some unusual pattern in the way the error is being generated. I
don't know that there's anything on the SQLAlchemy side that can address
Hi everyone!
I'm building a Pylons webapp using SA 0.6.4 and MySQL-Python 1.2.3.
Right now I'm writing the first change script for sqlalchemy-migrate
(just 3 lines of SQL).
I noticed that if the change script contains some syntax error, SA
catches the exception (in pool.py) and logs a
Error
On 17 Nov, 21:41, Michael Bayer mike...@zzzcomputing.com wrote:
I'll also make the comment that while the pattern you're illustrating is very
unusual (cascade turned off, re-adding detached objects), the ORM is not
being consistent in its treatment of non-included child items in mutated
Hi everyone!
I'm puzzled by a behaviour shown by SA 0.6.5 that 0.5.8 didn't show,
and I'm wondering what I'm doing wrong.. I have a simple uncascaded
many-to-many relationship, and if I try the following:
1) save a child
2) close the session
3) associate the child to a parent and save the parent
On 15 Nov, 18:57, Michael Bayer mike...@zzzcomputing.com wrote:
First off, I can't reproduce your issue:
Found the culprit: I had a stray 0.5.8 directory lying around, and of
course it was being picked up.. T_T Sorry :(
Second, if you want to switch to newer declarative features, just stick
Hi everyone!
I'm trying to port my application from SA 0.5.8 to 0.6.5, and I'm
having a problem with __mapper_args__.. :/
The application uses the declarative plugin, and every class derives
from a customized declarative base that aims to add to each one the
version_id_col.
Right now the code is
Hi everyone!
I'm using the Declarative plugin to generate/handle a DB of about 50
entities, with every kind of relation between them. I've just added a
simple one-to-many relation, and now SA is complaining that:
sqlalchemy.exc.CircularDependencyError: Circular dependency detected
[(base_files,
It looks like I should tinker with the use_alter parameter.. :)
--~--~-~--~~~---~--~~
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 23 Ott, 19:19, Mike Conley mconl...@gmail.com wrote:
I'm trying to automatically build a shallow copy of a SA-mapped
object.. At the moment my function is just:
newobj = src.__class__()
for prop in class_mapper(src.__class__).iterate_properties:
setattr(newobj, prop.key,
On 26 Ott, 13:41, Mike Conley mconl...@gmail.com wrote:
I see, but I need a proper shallow copy instead, with every
attribute.. Is there no way? :/
What is missed?
I am not sure what you mean by shallow copy. The fact that there are
relations to be lazy loaded is present in the new
On 26 Ott, 15:29, Mike Conley mconl...@gmail.com wrote:
So, in Python a non-automatic shallow copy would be:
A = Some_class()
A.refs = [B, C]
Acopy = Some_class()
Acopy.refs = A.refs
My problem is that if A.refs has to be lazy loaded, when I try to copy
it over to Acopy, it
In the end I followed the suggestion at
http://stackoverflow.com/questions/1510018/compound-uniqueconstraint-with-a-function
Many thanks for chiming in all the same :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Hi everyone!
I have a class Document with attributes Number and Date, is
there a way to set a UniqueConstraint on Number + year(Date)?
(SQLAlchemy 0.5.5, PostgreSQL 8.3.4)
Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are
On 2 Ott, 10:42, Joril jor...@gmail.com wrote:
I have a class Document with attributes Number and Date, is
there a way to set a UniqueConstraint on Number + year(Date)?
Self-followup: should I use a unique Index instead? But how do you
create a functional index in SQLAlchemy
Hi everyone!
I have a simple Invoices class with a Number attribute that has to
be filled in by the application when the user saves an invoice. There
are some constraints:
1) the application is a (thin) client-server one, so whatever
determines the number must look out for collisions
2) Invoices
On 24 Giu, 16:28, Michael Bayer mike...@zzzcomputing.com wrote:
whats the second question ? is this expected? yes. TypeEngine objects
don't have anything to do with default value generation.
I see, thanks!
--~--~-~--~~~---~--~~
You received this message
On 19 Mag, 01:03, Michael Bayer mike...@zzzcomputing.com wrote:
you'd have to roll that yourself. Its generally not feasable for
every relation on an object to be eagerloaded since it would create
too many joins.
I see, I'll just choose eager loads manually depending on context
then,
Hi everyone,
I'm sorry, is there an RSS feed somewhere with just the announcements
of SA's new releases?
Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to
Hi everyone!
I'm trying to concoct a somewhat complicated query via Query API.. The
situation is the following:
- A many-to-one relation between classes C and D
- Class C has an attribute value
My objective is to retrieve the ids of a left outer join between D and
C (so, all the Ds and
On 10 Apr, 12:52, a...@svilendobrev.com wrote:
that's what i have in bitemporal queries.
u need a groupby and subquery/ies.
I see, thanks for your hint!
I tried to do it with bare SQL via pgadmin, and I ended up with
select d.id, c.id from d left outer join (
select c.* from c join (
On 10 Apr, 15:43, Mike Conley mconl...@gmail.com wrote:
Try this, has one nested query
sub = session.query(C.id.label('c_id'),
C.d_id.label('d_id'),
func.max(C.value).label('c_maxvalue')
).group_by(C.d_id).subquery()
I tried something like that earlier, but
On 10 Apr, 15:54, Mike Conley mconl...@gmail.com wrote:
This will teach me to run a test it first, I don't think this is exactly
right, but it should be close.
That's ok all the same, thanks for taking the time for posting :)
Anyway my current implementation via Query API is
sub =
On 10 Apr, 16:24, Joril jor...@gmail.com wrote:
Now let's see if I can fetch complete instances of C instead of just
the id X-)
For the record, my final implementation:
sub = s.query(C.d_id, func.max(C.value).label(v)).
group_by(C.d_id).subquery()
sub2 = s.query(C).join((sub
On 26 Mar, 18:02, Michael Bayer mike...@zzzcomputing.com wrote:
you can check if an object is an orphan related to a certain relation()
its supposed to belong to, though there's no automated way to go from that
object to the actual collection it was removed from unless you scan
through all
Hi everyone!
I have a simple many-to-one relation between class A and class B, and
I'd like to use a Query to get the A instances sorted by a B
attribute (e.g. code).. I tried with something like this:
q = session.query(A)
q.order_by(A.list_of_b.code)
but obviously list_of_b doesn't know about
On 19 Mar, 15:09, Martin mar...@chinasoftinc.com wrote:
I guess
q = session.query(A).join('b').order_by(B.code).all()
should do the trick, at least it did under 0.4.8
It works in 0.5.2 too, thanks :)
I was wondering though, maybe 0.5.x has a way to do it without the
join? I mean, SQLA
On 5 Mar, 18:40, Michael Bayer mike...@zzzcomputing.com wrote:
im finding it easiest to just autoload the tables in my migrate script.
That way there's no cut and paste the table def going on, you just load
them as they are from the DB. and the schema definition stays in the
database for
Hi everyone!
I'm looking for a way to handle database migrations/upgrades and found
projects such as sqlalchemy-migrate and mikuru.. My understanding is
that those projects expect the model to be in NON-declarative form,
that is, with users_table = Table(...) and the like.. But what if my
program
Hi everyone!
I have a simple one-to-many relation between two classes, and I'm
trying to serialize/deserialize an any restriction on them.. My
problem is that deserialization fails with maximum recursion depth
exceeded.
Am I doing something wrong?
Here's my testcase:
from sqlalchemy import
Michael Bayer wrote:
meta = MetaData()
Base1 = declarative_base(metadata=meta, metaclass=MyMetaClass)
Base2 = declarative_base(metadata=meta, metaclass=MyOtherMetaClass)
Base2._decl_class_registry = Base1._decl_class_registry
Great!
So now I have a MetaClass2 that extends MetaClass1, and
Michael Bayer wrote():
isinstance(obj, (Base1, Base2)), or you could make yet another Base
class below Base1 and Base2 and specify it as cls to
declarative_base().
I see.. Thanks again, you are very helpful!
--~--~-~--~~~---~--~~
You received this message
Michael Bayer ha scritto:
hibernate-style custom types are documented here:
http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html?highlight=typeengine#custom-types
or you can use PickleType.
Perfect, many thanks!
--~--~-~--~~~---~--~~
You
Hi everyone!
Is there a way to (declaratively) map a class so that one of its
members is an array of strings?
(As an example use-case, a User class with an array of her websites)
With Hibernate I'd just register a custom persister that would
serialize the array/list to a big varchar field, is
Hi everyone!
Is there a way to pickle a Query restriction?
If I try this:
import cPickle
restr = (MyDataClass.intproperty==1)
cPickle.dumps(restr, 1)
I get a
cPickle.PicklingError: Can't pickle class
'sqlalchemy.orm.properties.ColumnComparator': attribute lookup
Michael Bayer ha scritto:
There's a new extension in 0.5 which allows pickling of any ORM
structure called sqlalchemy.ext.serializer.
I see, thanks :)
Although the error below shouldn't occur in any case, try out the latest
trunk.
Do you mean normal Pickle shouldn't raise the
Quite complicated, I see X-)
Anyway, I've been able to implement the clean way you suggested (or
at least the test suite says so :) ).. Many thanks again for your
time, you've been very helpful!
(Thanks to Svil too for your contribution!)
--~--~-~--~~~---~--~~
You
On 19 Nov, 16:28, Michael Bayer [EMAIL PROTECTED] wrote:
a guaranteed stable way that doesn't rely on SQLAlchemy implementation
details and is easy to understand is here. this is how I would do it:
http://pastebin.com/f6670eebe
I see, many thanks for yor time :)
Out of curiosity, is there a
On 19 Nov, 17:22, Michael Bayer [EMAIL PROTECTED] wrote:
Out of curiosity, is there a solution that wouldn't require creating
new instances of the objects?
(Some magic incantation like the del instance_state(entity).key you
suggested me some time ago, I guess..?)
not really since you'd
On 5 Nov, 18:17, Joril [EMAIL PROTECTED] wrote:
I'd like to add a filter to a relation, so that it ignores records of
the remote table if they're flagged as logically_deleted (a
boolean field of the child table)
Solved,
children = relation(Child, primaryjoin=and_(id == Child.parent_id
Hi everyone!
I tried googling but found nothing.. Is there a way to know beforehand
whether a relation would be lazy-loaded?
For example, given a lazy parent-children relation and an instance X
of parent, I'd like to know if X.children is already loaded,
without triggering the query.
Thanks in
Lawrence Oluyede ha scritto:
Have a look here:
http://www.sqlalchemy.org/docs/05/plugins.html#plugins_declarative
Didn't think of looking at the plugins section at all X-) Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
Hi everyone!
I'm sorry, I can't find documentation on how to specify relations
using the declarative syntax.. Could someone provide a pointer?
Thanks for your time!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Hi everyone!
I'm looking for a way to log queries at a higher level than SQL.. That
is, given the class
Base = declarative_base()
class DataTest(Base):
id = Column(Integer, primary_key = True)
propb = Column(Boolean)
__tablename__ = t
right now when I try to print a query
Hi everyone!
I'm trying to implement data logging with SQLAlchemy.. That is,
whenever someone updates a persisted entity, generate a new record and
then mark the old one as such.
My problem right now is that if I load an entity from the DBMS, modify
it and then try to save it again, I have to
Perfect! Thanks again!
--~--~-~--~~~---~--~~
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
On 6 Ott, 16:26, Michael Bayer [EMAIL PROTECTED] wrote:
Alternatively you could visit and compile the clause directly with
your own compiler, which subclasses compiler.DefaultCompiler and
overrides visit_bindparam() to return a string representation of the
data instead of a param name.
I
Hi everyone!
I'm sorry, I'm using SQLA 0.5rc1 with autocommit=True, and I'm having
a problem with rollbacks.. It looks to me that whenever I try to save
an object that triggers some kind of exception (thus triggering a
rollback) I lose that object's previous state..
To elaborate, here's a simple
Hi everyone!
I'm new to SQLAlchemy and I'm using version 0.5rc1..
I need every entity class to have a few common fields, so I tried
writing an abstract base class, declarative-style, that every other
entity class would subclass. So for example:
---
from sqlalchemy.ext.declarative import
I don't know whether this is currently possible with Declarative or
not. In the case it isn't, patching Declarative should be quite easy
(but I don't know if such a patch would be accepted or not).
I see.. I'll wait a bit then, maybe one of the developers will tell us
if it'd be acceptable :)
Hi everyone!
I'm sorry, I tried the documentation but couldn't find this piece of
information.. How do I implement optimistic locking with SA? I mean,
is there a framework for versioning fields? (The way Hibernate does)
Should I do it by hand?
Many thanks for your attention!
Oops, found version_id_col at
http://www.sqlalchemy.org/docs/adv_datamapping.html,
sorry!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to
63 matches
Mail list logo