I would first figure out how you would do this in SQL, and then
translate that to SQLAlchemy. In this case, the EXISTS operator might
work:
SELECT *
FROM department
WHERE EXISTS (
SELECT 1
FROM employee
WHERE employee.department_id = department.id
AND employee.name IN (...)
)
LIMIT
Using ORM querying what is the best practice for limiting the output to a
given number of resulting *entities*?
Consider this model:
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import
On 05/02/2017 12:38 AM, Isaac Martin wrote:
Thank you very much for your response. This solution isn't working for
me, and I'm 99% sure I'm not translating what you've written into
something that works for my use case. My situation is somewhat more
complicated than I initially wrote. My first
Well that was a very silly mistake. End of the day oversight is what
happened here. I didn't notice that "offset" was set to 10 and my unit test
only had 2 values. When I set offset to 0 it worked great.
Sincerest thanks for this! I hadn't seen as_scalar used before. I'm looking
forward to trying
Thank you very much for your response. This solution isn't working for me,
and I'm 99% sure I'm not translating what you've written into something
that works for my use case. My situation is somewhat more complicated than
I initially wrote. My first question was in the vain hope that there was
some
On 05/01/2017 08:05 PM, Isaac Martin wrote:
I am building an api which can return children of resources if the user
requests it. For example, |user| has |messages|. I want the query to be
able to limit the number of |message| objects that are returned.
I found a useful tip about limiting t
I am building an api which can return children of resources if the user
requests it. For example, user has messages. I want the query to be able to
limit the number of message objects that are returned.
I found a useful tip about limiting the number of objects in child
collections here
The Sybase dialect supports rendering of the "TOP" and "START AT" clauses when
you use the limit() and offset() constructs of select().
So if you're using Core SQL select() constructs or the ORM Query, it should
work at least rudimentally.
On Mar 26, 2014, at 4:19 AM, angad nath wrote:
> Hi A
Hi All,
I am trying to port my application from MySQL to Sybase ASE 15.7 version.
How can i implement my query using LIMIT and OFFSET using sqlalchemy 0.8
targeting Sybase ASE 15.7 ?
Thanks,
Angad Nath
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy"
I've been looking for a way to limit and offset custom sql statement.
I can't use query from orm or select with limit and offset methods.
I simply get sql string which I execute.
q = text(sqlstr)
res = session.execute(q).fetchall()
I want to have some paging of the result. I've come out with sort
Kent wrote:
> The limit() function behaves in a way that is possibly unexpected:
>
> If you ask sqlalchemy to query "limit(3)" where a join is involved,
> for example, and 2 of the "top-3" are actually the same primary key,
> sqlalchemy gets the 3 results, throws out the duplicate and your query
>
The limit() function behaves in a way that is possibly unexpected:
If you ask sqlalchemy to query "limit(3)" where a join is involved,
for example, and 2 of the "top-3" are actually the same primary key,
sqlalchemy gets the 3 results, throws out the duplicate and your query
size ends up as 2. Thi
Hello.
I'm trying to write some kind of framework web, but i would like to use
sqlalchemy, but i need to make a paged result, and every DB has a way to
limit the query...
Is there a way to do this in alchemy? Note: it's a query defined in xml, so
i use pure sql (this part will just use the alchem
I have query on a view that looks like this:
query= dbSession.query(_class).filter('entry_status = 2').order_by
( _class.c.entry_authored_on.desc() ).limit(3).offset(0)
results= query.all()
print query
print " - - - - - -"
print results
print "== == =="
this always returns no results.
howe
Hi,
Yesterday I was searching this group and the SA 5.0 doc to get something
working. Somewere I came across an option to specify the columnames to
return
(and getting a tuple or so)
Let me explain:
Keep the following in mind:
I have a table which stores files defined with Declarat
Morning Guys,
I hope this'll be a fairly simple question. I have a query which looks
something like this:
the_objects = session.query(myobject.myobject).filter("myobject.created >
:lastrecord").params(lastrecord=time.strftime("%Y-%m-%d %H:%M:%S",
from_date)).all()
This grabs all the rec
Hi,
after reading the docs [1] I thought that something like
session.query(User).filter(User.c.id > 3)[0]
should work even if the filter clause does not return any rows.
But - compliant with Python's behavior - SQLAlchemy raises an
IndexError.
(...)
File "/usr/lib/python2.4/site-packages/sqla
Hi,
I'm trying to determine a way to append a LIMIT to an update()
object.
Is the solution a correlated update on the same table with the LIMIT
on the select() object?
Cheers,
Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to t
Hi,
The ancient version of MySQL that I am connecting to (3.23.58) doesn't
support the syntax 'LIMIT OFFSET ' syntax. Instead, it
uses LIMIT , . This is described in the docs, but it
doesn't say what version introduced the more standard syntax:
http://dev.mysql.com/doc/refman/5.0/en/select.html
Hi,
I was trying to write a query where the limit clause was actually a
bind param, however it appears that, (in 3.10), this isn't possible.
Am I missing something, or is this a bug?
for example I'm just doing
s = select ([Table], whereclause, limit=bindparam('mylimit'))
s.execute(mylimit=5)
C
default of limit is None.
All those query.select arguments go in a orm.query.QueryContext()
do see its __init__ for which arg has what default.
On Tuesday 17 April 2007 09:31:04 Disrupt07 wrote:
> I am defining my result list the following way:
>
> result = queryobject.select(mytable.c.columnname
I am defining my result list the following way:
result = queryobject.select(mytable.c.columnname == columnname, limit
= maxResults, offset = 0)
maxResults is the number of records I want returned. In case I want
all the records, I am setting maxResults as -1. However, this is not
working for m
22 matches
Mail list logo