mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Fixed csvexport to write in primary key order.
Good news: This no longer relies on InnoDB's default row order. Bad news: InnoDB in MySQL 5.0 has a bug where it will sort rows physically according to a secondary index, if there's a composite primary key and a single-column index and the phase of the moon is right. So a couple tables have been, once again, reordered -- but correctly this time. Good news: This bug will no longer fuck me up!
This commit is contained in:
parent
cce9c26125
commit
64d3c7d5f1
4 changed files with 1895 additions and 1894 deletions
pokedex
|
@ -142,7 +142,8 @@ def command_csvexport(engine_uri, directory='.'):
|
|||
columns = [col.name for col in table.columns]
|
||||
writer.writerow(columns)
|
||||
|
||||
for row in session.query(table).all():
|
||||
primary_key = table.primary_key
|
||||
for row in session.query(table).order_by(*primary_key).all():
|
||||
csvs = []
|
||||
for col in columns:
|
||||
# Convert Pythony values to something more universal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue