thombashi / sqlitebiter

A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
https://sqlitebiter.rtfd.io/
MIT License
850 stars 50 forks source link

SQL table name cannot start with numeric? #76

Closed longxudou closed 4 years ago

longxudou commented 4 years ago

What happens?

I met a bug when I try to convert the following json into sqlite file.

{ "2018Asset": [ { "RANK": "1", "id": "item_entertainment_18_212", "count": "1billion" } ] }

What were you expecting to happen?

Convert succeed.

What are the steps to reproduce this issue?

command: sqlitebiter -o 'test.sqlite' file 'test.json'

Any logs, error output, etc?

I turn on the debug mode. DEBUG | simplesqlite.core:create_table:1261 - CREATE TABLE IF NOT EXISTS '2018Asset' (RANK INTEGER, id TEXT, count TEXT)

Environments

Any other comments?

After detecting the table name starting with the number, the command should be 'CREATE TABLE IF NOT EXISTS [2018Asset] ...' instead of 'CREATE TABLE IF NOT EXISTS 2018Asset ...'. We can escape the table's name by enclosing it with []:

thombashi commented 4 years ago

@DreamerDeo Thank you for your report.

The issue fixed at sqlitebiter 0.31.1, you can convert the JSON file with this version. Please upgrade the package and re-execute.