Fair enough, thanks. I didn't realize it was such a complex task; I
figured it was just a matter of passing an argument to distinct() or
something equally easy. Speed isn't a huge concern, so I suppose I
could get around this by storing the item numbers I find and then
checking that the row I'm about to use doesn't have a number in that
set. Still, there could be hundreds of thousands of items, so that
might not be the best plan. Anyway, I'll look into it more.

On 3/9/16, Jonathan Vanasco <jonat...@findmeon.com> wrote:
> It would probably be best for you to figure out the correct raw sql you
> want, then convert it to SqlAlchemy.
>
> Postgres is the only DB I know of that offers "DISTINCT ON (columns)" --
> and even that works a bit awkward.
>
> The query that you want to do isn't actually simple -- there are concerns
> with how to handle duplicate rows (based on the distinct field).    Often
> people will use "GROUP BY" + "ORDER BY" along with distincts, subselects
> and misc database functions.
>
> If I were in your place, I would read through some DB tutorials and
> StackOverflow questions on how people are dealing with similar problems.
>  That should help you learn.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to