simonw / sqlite-history

Track changes to SQLite tables using triggers
Apache License 2.0
108 stars 2 forks source link

Can't handle tables with a column called "order" or other reserved words #2

Closed simonw closed 1 year ago

simonw commented 1 year ago

I'm going to copy in the sqlite_escape function from Datasette: https://github.com/simonw/datasette/blob/5890a20c374fb0812d88c9b0ef26a838bfa06c76/datasette/utils/__init__.py#L345-L349

simonw commented 1 year ago

That didn't fix it - against https://datasette.io/content.db :

% python -m sqlite_history content.db --all
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/simon/Dropbox/Development/sqlite-history/sqlite_history/__main__.py", line 68, in <module>
    run()
  File "/Users/simon/Dropbox/Development/sqlite-history/sqlite_history/__main__.py", line 64, in run
    configure_triggers(args.database_path, args.tables)
  File "/Users/simon/Dropbox/Development/sqlite-history/sqlite_history/__main__.py", line 20, in configure_triggers
    configure_history(db, table)
  File "/Users/simon/Dropbox/Development/sqlite-history/sqlite_history/__init__.py", line 12, in configure_history
    db.executescript(triggers_sql(table, columns))
sqlite3.OperationalError: near "order": syntax error