def generate_idump(day, **db_parameters): """Generate incremental dump for the given day. """ db.setup_database(**db_parameters) rows = db.longquery("SELECT data.* FROM data, version, transaction " + " WHERE data.thing_id=version.thing_id" + " AND data.revision=version.revision" + " AND version.transaction_id=transaction.id" + " AND transaction.created >= $day AND transaction.created < date $day + interval '1 day'" + " ORDER BY transaction.created", vars=locals(), chunk_size=10000) print_dump(row.data for chunk in rows for row in chunk)