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
Hi all
I use insert statement as text to insert record into MySQL DB. I chose
this method because I use INSERT in combination with SELECT, so there
is no way to use SQL Expression language. My problem is that there is
no inserted ids available after inserting data using raw SQL
statement. When I
that's what i have in bitemporal queries.
u need a groupby and subquery/ies.
something along
subs = select(
[C.id.label('cid'), C.d_id.label('did'),
func.max(C.value).label('cvalue')]
).group_by( C.id )
giving the max cid/cvalues, and then somehow join Ds with that.
D.query(
Hello everyone?
I need to translate following complex query into SQLA. How do I do that?
SELECT h.id AS hosts_id, h.ip AS hosts_ip, h.hostname AS hosts_hostname,
h.location AS hosts_location, h.architecture_id AS
hosts_architecture_id, h.os_kind_id AS hosts_os_kind_id, h.os_version_id
AS
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 (
Hello everyone,
From time to time I get this error when processing my own query in
from_statement:
ProgrammingError: (ProgrammingError) current transaction is aborted,
commands ignored until end of transaction block
\nSELECT h.id AS hosts_id, h.ip AS hosts_ip, h.hostname AS
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()
q = session.query(D.id,sub.c.c_id,sub.c.c_maxvalue).outerjoin(sub)
print q
for row in q:
print 'D-id:%s
This will teach me to run a test it first, I don't think this is exactly
right, but it should be close.
--
Mike Conley
On Fri, Apr 10, 2009 at 9:43 AM, 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'),
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,
call result.lastrowid. you'll get whatever the DBAPI deems worthy of
sending.
Andrija Frincic aka BobRock wrote:
Hi all
I use insert statement as text to insert record into MySQL DB. I chose
this method because I use INSERT in combination with SELECT, so there
is no way to use SQL
SQLA can execute your query as text. For an existing query like this, I'd
stick with that unless you require DB-neutral behavior or other
malleability. The constructs used would be the standard Table objects,
join objects, etc. all described in the SQL Expression Tutorial.
Marcin Krol wrote:
Marcin Krol wrote:
Hello everyone,
From time to time I get this error when processing my own query in
from_statement:
ProgrammingError: (ProgrammingError) current transaction is aborted,
commands ignored until end of transaction block
a previous statement failed within the transaction
Michael Bayer wrote:
From time to time I get this error when processing my own query in
from_statement:
ProgrammingError: (ProgrammingError) current transaction is aborted,
commands ignored until end of transaction block
a previous statement failed within the transaction and must be
In 5.2 I was able to map a base-class, and sub-classes would
automatically be persisted as the base type. In 5.3 I get an
UnmappedInstanceError when trying to persist an object of the sub-
class type. I didn't see anything about this change in the changelog.
Is there a way to get the 5.3
Hello,
I wanted to use a custom type as an auto-increment / primary key in
one of my
tables. The type is made like this:
class BoxId (sqlalchemy.types.TypeDecorator):
impl = sqlalchemy.types.Integer
Using it in a table like this:
box = Table ('box', metadata,
Column ('id',
limscoder wrote:
In 5.2 I was able to map a base-class, and sub-classes would
automatically be persisted as the base type. In 5.3 I get an
UnmappedInstanceError when trying to persist an object of the sub-
class type. I didn't see anything about this change in the changelog.
Is there a way
warp wrote:
Hello,
I wanted to use a custom type as an auto-increment / primary key in
one of my
tables. The type is made like this:
class BoxId (sqlalchemy.types.TypeDecorator):
impl = sqlalchemy.types.Integer
Using it in a table like this:
box = Table ('box', metadata,
19 matches
Mail list logo