Hi,
I have the following situation:
There are two tables, A and B , both of which have an id column.
In a certain part of the code I have an ORM query object.
That query object is returned by some function and I have no apriori
knowledge of its structure.
I am assured, though that there will be
I have the following mapper:
orm.mapper(Xxx,xxx_table, inherits=Resource,
polymorphic_identity=u'xxx',
properties={'children' : orm.relation(Xxx,
backref=orm.backref('parent', remote_side=[Xxx.c.id]),
I seem to have solved it by aliasing the first instance too
query = sqlalchemy.orm.query(Xxx)
*alias = SA.orm.aliased(Xxx)*
query = query.join(*(alias,'parent')*, aliased=True)
query = query.filter(some criterion)
But this
other processes get a chance at querying.
The ORDER BY is just for aesthetics, so that I always delete the
oldest ones first and not create holes, but I can live without it.
On Jun 14, 2:32 pm, Rami Chowdhury rami.chowdh...@gmail.com wrote:
On Mon, Jun 13, 2011 at 15:42, Moshe C. mos
Hi,
I am using Sqlalchemy 0.6.5 .
How do I generate the following statement usin Sqlalchemy expressions
(not ORM).
DELETE FROM table ORDER BY timestamp LIMIT 10;
TIA
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send
/compiler.html
On Jun 13, 2011, at 10:10 AM, Moshe C. wrote:
Hi,
I am using Sqlalchemy 0.6.5 .
How do I generate the following statement usin Sqlalchemy expressions
(not ORM).
DELETE FROM table ORDER BY timestamp LIMIT 10;
TIA
--
You received this message because you
What replaces the keys() method of PrimaryKeyConstraint that existed
in 0.4 ?
TIA
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
How do I write an expression (in sqlalchemy 0.4.6) that will generate
the following expression:
select count(distinct field1, field2) from tableA;
I know how to do it for one field and I know how to do it with no
count using distinct=True, but not this combination.
--
You received this
Trying to find out if I hit a bug or it is me doing something wrong.
Using version 0.4.6
when creating an object and then calling session.save() I get:
Instance 'res...@-0x486e4074' is already persistent
It works save_or_update() with, but I don't see why I should use that.
I did read that
Thanks.
Given that I am not going to upgrade very soon, is it right to
conclude that there was a bug in 0.4.6, or is my usage wrong?
On Jun 3, 5:28 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Moshe C. wrote:
Trying to find out if I hit a bug or it is me doing something wrong.
Using
for a related object, makes the
Resume object not transient anymore?
On Jun 3, 8:56 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Moshe C. wrote:
Thanks.
Given that I am not going to upgrade very soon, is it right to
conclude that there was a bug in 0.4.6, or is my usage wrong
. There is a relation between the objects, but it is not
clear how querying on another object makes the Resume object non-
transient.
On Jun 3, 10:55 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Moshe C. wrote:
Well, I thought it was transient.
If you refer to the code in the first post:
your
Weird, the first assertion already fails, but I am not using
ScopedSession.mapper. See the code in the first post.
On Jun 3, 11:28 pm, Michael Bayer mike...@zzzcomputing.com wrote:
easy way to ensure things are working as expected:
Moshe C. wrote:
In code:
t = Model.Resume
):
Model.session.save_or_update(obj)
def flush(self):
Model.session.flush()
def delete(self, obj):
Model.session.delete(obj)
def clear(self):
Model.session.clear()
On Jun 3, 11:47 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Moshe C. wrote:
Weird, the first assertion
Let's say I have a many to many relationship as for example in:
orm.mapper(self.Person, person_table, properties = {
'relatives' : orm.relation(self.Person,
secondary=person_relative_table,
primaryjoin=person_table.c.id==person_relative_table.c.person_id,
Table T has a self referential parent_id column. 'parent' is an
orm.relation using that column.
I have the following code which obviously does not work
myquery = T.query()
myquery = myquery.outerjoin('parent', aliased=True)
myquery = myquery.reset_joinpoint()
myquery =
How can I prevent aliases fro appearing in the query?
I have hit a MySQL bug that is related to a very biq SQL query string
being sent and I am trying to shorten it.
I might need an alias on one of the columns, though.
The query is created originally by ORM query.compile() and then I
create a
How would I unmap a class ( so that I can map it to another table from
a parallel but distinct DB) ?
I can't seem to find the documentation for the Mapper object itself.
I may be going the wrong way about it.
I want to map the same class to tables in different databases at
different times.
this correctly, I don't really need to touch the
mappings at all since the tables remain the same, but just change the
connection.
I'll try it out.
On Nov 25, 5:25 pm, Michael Bayer [EMAIL PROTECTED] wrote:
Moshe C. wrote:
How would I unmap a class ( so that I can map it to another table from
a parallel
The ScopedSession class has no bind_table method.
Is there a way to get at a Session object from ScopedSession object?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send
table.update(criterion, values={'last_edited' : func.now()} ).execute
()
works
but
table.update(criterion ).execute({'last_edited' : func.now()})
does not. It tries to set 'last_edited' to functions object.
Can someone clarify the difference ?
For Query there is an add_column() method, but I do not see a remove
column method.
Initializing a Query requires a full mapped class, so how can I select
on only a subset of the columns.
I want to do this for ding a DISTINCT query on only a couple of
columns.
TIA
Moshe
0.4.6
On Nov 19, 11:12 pm, Bobby Impollonia [EMAIL PROTECTED] wrote:
What version of SQLA are you using? In .5 , you can pass individual
columns instead of a mapped class to session.query.
On Wed, Nov 19, 2008 at 12:17 PM, Moshe C. [EMAIL PROTECTED] wrote:
For Query there is an add_column
a look at the changelog to see what
bugs have been fixed between 0.4.6 and 0.4.8.
Moshe C. wrote:
I have tried it out on 0.4.6 and it is working nicely.
You mentioned 0.4.7 .
Is there any bug I should be aware of in 0.4.6?
I cannot upgrade in the near future.
On Nov 20, 12:19 am, Michael
Hi,
Given a mapped ORM class, is it possible to retrieve from it the Table
instabce to which it was mapped?
TIA
Moshe
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send
No, I am not using declarative .
On Nov 17, 2:43 am, Bobby Impollonia [EMAIL PROTECTED] wrote:
Are you using declarative? If so, your class will have a property
called __table__
On Sun, Nov 16, 2008 at 4:04 PM, Moshe C. [EMAIL PROTECTED] wrote:
Hi,
Given a mapped ORM class
thanks
On Nov 17, 2:53 am, Michael Bayer [EMAIL PROTECTED] wrote:
class_mapper(theclass).mapped_table
On Nov 16, 2008, at 7:50 PM, Moshe C. wrote:
No, I am not using declarative .
On Nov 17, 2:43 am, Bobby Impollonia [EMAIL PROTECTED] wrote:
Are you using declarative? If so, your
Let's say you have two concurrent processes where each might increment
some integer field in some table row.
If you query first and the increment in memory and then update, you
need to query with_lockmode('update') to avoid the case where both
processes read the same value and the do the same
Hi,
I have an autoflush session and I need it to be so.
For one specific query though, I would like no flush to occur.
How can I set an existing autoflush session to not autoflush and then
reset it back to autoflush?
TIA
Moshe
--~--~-~--~~~---~--~~
You received
regarding union, maybe I am missing something basic. I use the
session.query() with the orm stuff. How do I get the selects from
those ?
On Jun 17, 8:23 pm, Michael Bayer [EMAIL PROTECTED] wrote:
On Jun 17, 12:49 pm, Moshe C. [EMAIL PROTECTED] wrote:
I have 3 tables:
general_product {id
?
On May 27, 5:42 pm, Michael Bayer [EMAIL PROTECTED] wrote:
On May 27, 2008, at 4:39 AM, Moshe C. wrote:
I have the following mapping for classes One and Many:
mapper(One, one_table, properties={'many':relation(Many)})
mapper(Many, many_table)
and the following query
I have a mapper created with a mapper extension that has an
after_update() override.
For a table in the mapper I do an update and then a commit().
This is the resulting order of execution:
update instance (setting an attribute on the mapped class)
commit
after_update called on instance
I.e.
PLEASE IGNORE PREVIOUS.
It turns out that explicitly flushing does change the order (made a
silly coding error before).
I am all set, but the question remains why autoflush isn't enough.
On May 23, 2:15 pm, Moshe C. [EMAIL PROTECTED] wrote:
I have a mapper created with a mapper extension
I traced what is happening in the code.
I don't fully understand it but I hope the following will help.
The crucial point is that in my after_update() method I create a
mapped object and call session.save() using the same session (but
different table).
This is the sequence of events:
- I call
[EMAIL PROTECTED] wrote:
On May 23, 2008, at 6:54 PM, Moshe C. wrote:
I traced what is happening in the code.
I don't fully understand it but I hope the following will help.
The crucial point is that in my after_update() method I create a
mapped object and call session.save() using the same
This is probably very simple, but I am searching the docs and not
finding the answer :-(
In 0.3 I had a working statement of the form:
engine.execute(table.select(), cond_dict)
where cond_dict is a dictionary of column names mapped to values.
In 0.4.6 this does not work. What is produced in SQL
Thanks.
So I guess you cannot use the dictionary argument as is. It was very
convenient.
On May 21, 6:16 pm, Michael Bayer [EMAIL PROTECTED] wrote:
On May 21, 2008, at 11:06 AM, Moshe C. wrote:
This is probably very simple, but I am searching the docs and not
finding the answer
Got back to this issue after a while.
The SessionExtension objects allows me to hook on to a session and get
notified of various events.
My question is different:
Given a session, before commit, how can I query it to know what is
going to happen at commit.
My intention is to derive from that, a
Hi,
Node is an orm mapped class, which is self-referential.
myquery = Node.query()
myquery = myquery.join('parent', aliased=True)
myquery = myquery.filter(Node.c.desc.like('%something'))
myquery = myquery.order_by(Node.c.name)
The last line orders by the 'name' of the 2nd joined table.
How
._order_by + criterion
TypeError: can only concatenate list (not tuple) to list
On May 6, 8:45 pm, Michael Bayer [EMAIL PROTECTED] wrote:
On May 6, 2008, at 1:43 PM, Moshe C. wrote:
Hi,
Node is an orm mapped class, which is self-referential.
myquery = Node.query()
myquery
= myquery.reset_joinpoint().order_by(Node.c.popularity) #
_aliases_tail is None for this call
On May 6, 10:25 pm, Michael Bayer [EMAIL PROTECTED] wrote:
On May 6, 2008, at 3:08 PM, Moshe C. wrote:
Both methods cause a crash (yes, on 0.4.5) .
converting a tuple to a list in sqlalchemy
Is it possible to retrieve mapped objects from a session.
The motivation: I want to maintain history log tables where a row is
added per each update or insert on the corresponding main table. The
schema of the tables is identical except for an additional timestamp
in the history table.
I want
The following line:
r = cnnctn.execute(insert(t),
{'xkey': 'k1','yval':1},
{'xkey': 'k2','yval':2},
{'xkey': 'k3'})
Cause the following :
INSERT INTO `A` (xkey, yval) VALUES (%s, %s)
[['k1', 1], ['k2', 2], ['k3', 1]]
i.e. the unspecified value in the
Raising this after 3 days, still hoping for help :-)
--~--~-~--~~~---~--~~
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
('select 1')
On 8/30/07, Moshe C. [EMAIL PROTECTED] wrote:
How can I test whether a connection object is valid and hasn't, for
example, been time outed by the server?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
45 matches
Mail list logo