Then i try to import following .csv file

col1;col2
1;1
2;2
3;3

with .import command into a table with name what contents "-" sign

sqlite> .open test.db
sqlite> drop table if exists [my-test-table];
sqlite> .mode csv
sqlite> .separator ;
sqlite> .import 'my-test-table.csv' [my-test-table]

And here sqlite3 returns the following error: "Error: no such table:
[my-test-table]"

However, a table with name " my-test-table" was created in the database and
is empty

sqlite> .schema
CREATE TABLE [my-test-table](
  "col1" TEXT,
  "col2" TEXT
);

and the command
sqlite> SELECT * FROM [my-test-table];
returns none.

I try the latest precompiled sqlite3 binary from sqlite.org and binary
compiled from sqlite-amalgamation-3240000.zip source.

So, when I replace
sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
with
sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zTable);
in function do_meta_command on line 13700 of shell.c file
from sqlite-amalgamation-3240000.zip and recompile sqlite3 all works fine.

The CREATE TABLE statement on line 13658 in this file use %s modifier for
table name
char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);

I think, that the same %s modifier should be used in INSERT INTO statement.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to