Closed maheshkumar2150 closed 5 years ago
Hi @maheshkumar2150
Did you mean adding primary key autoincrement column to the SQLite file while JSON does not include a key column? like the following example:
[
{
"a": "foo",
"b": 123
},
{
"a": "bar",
"b": 456
}
]
'issue60' (a INTEGER, b INTEGER);
a | b |
---|---|
foo | 123 |
bar | 456 |
'issue60' (id INTEGER PRIMARY KEY AUTOINCREMENT, INTEGER, b INTEGER);
id | a | b |
---|---|---|
1 | foo | 123 |
2 | bar | 456 |
Yes. Exactly, this is what i wanted to ask. Is it possible?
Thank you for your reply.
You can add primary key id column as described in the previous comment with sqlitebiter 0.25.0 or newer version. I had added the feature to that version.
Please upgrade sqlitebiter and execute with --add-primary-key <PRIMARY KEY NAME>
option like following:
[
{
"a": "foo",
"b": 123
},
{
"a": "bar",
"b": 456
}
]
$ sqlitebiter --add-primary-key id file issue60.json
[INFO] sqlitebiter file: convert 'issue60.json' to 'issue60' table
[INFO] sqlitebiter file: converted results: source=1, success=1, created-table=1
[INFO] sqlitebiter file: database path: out.sqlite
Field | Type | Null | Key | Default | Index | Extra |
---|---|---|---|---|---|---|
id | INTEGER | NO | PRI | NULL | X | |
a | TEXT | NO | NULL | |||
b | INTEGER | NO | NULL |
Super! Thank you so much!!
Hi
How do i add auto increment primary column while converting json to sqlite. Thanks for this awesome plugin.