I have a MySQL database with a few thousand forum posts + text. I would like to grab them in batches, say 1000 at a time, and do stuff to them in python3.
My single post query looks like:
pquery = session.query(Post).\
filter(Post.post_id.like(post_id))
How can I change this so that given a post_id, it returns that post and the 999 posts after it?
Use limit
and offset
:
pquery = session.query(Post).filter(Post.post_id.like(post_id)).limit(1000).offset(the_offset_val)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With