I don't use MySQL either (only if I have to)

Before I was using sqla I inserted using plain SQL and noticed that I
lost a lot of inserts when bulk-importing data (up to 25% !) because
MySQL couldn't handle it. Never really dug into it, but just started
using Postgres (and very happy about it)


On Apr 13, 10:00 pm, Conor <[email protected]> wrote:
> Richard de Koning wrote:
> > Thanks Conor. It works like a charm.
>
> > You gave me a lot of insight in using sqla more flexible. Up to now
> > I'm having very long statements but your way is much more self-
> > explanatory than my own long versions.
>
> > I didn't now the yield_per. Why is it only for non-MySQL databases?
>
> I don't really use MySQL myself, but I've heard on this list that the
> mysqldb DBAPI implementation always stores the resultset in memory
> before passing it on to the client (or SQLAlchemy in this case). AFAIK
> most other DBAPI implementations properly fetch XXX rows at a time when
> you do a fetchmany, so SQLAlchemy can take advantage of that.
>
> -Conor
>
> > On Apr 13, 8:30 pm, Conor <[email protected]> wrote:
>
> >> Is this what you want? The query below ORs all your term clauses
> >> together, so it has the effect of merging the results.
>
> >> clauses = []
> >> for term in terms:
> >>     clauses.append(table.logtext.like(term))
> >>     clauses.append(table.titlelog.like(term))
>
> >> q = session.query(table)
> >> if len(clauses) > 0:
> >>     q = q.filter(or_(*clauses))
> >> q = q.order_by(desc(table.unixtime))
> >> # Reduce client memory usage for non-MySQL databases.
> >> q = q.yield_per(1000)
> >> for instance in q:
> >>     ...
>
> >> -Conor

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to