[BUG] shell: .import: no special characters in table name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] shell: .import: no special characters in table name

Clemens Ladisch
Hi,

the .import command does not work (and can show misleading error messages)
if the table name contains special characters:

  sqlite> .import test.csv temp.t
  Error: no such table: temp.t
  sqlite> select * from temp.t;
  sqlite>

This appears to be caused by inconsistent quoting of the table name:

    zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
      char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
    sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] shell: .import: no special characters in table name

Simon Slavin-3


On 19 Oct 2017, at 7:38pm, Clemens Ladisch <[hidden email]> wrote:

> the .import command does not work (and can show misleading error messages)
> if the table name contains special characters:
>
>  sqlite> .import test.csv temp.t

What format is the file "temp.t" in ?  UTF-8 ?  ASCII ?  Some sort of code page ?

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] shell: .import: no special characters in table name

Clemens Ladisch
Simon Slavin wrote:
> On 19 Oct 2017, at 7:38pm, Clemens Ladisch wrote:
>> the .import command does not work (and can show misleading error messages)
>> if the table name contains special characters:
>>
>>  sqlite> .import test.csv temp.t
>
> What format is the file "temp.t" in ?  UTF-8 ?  ASCII ?  Some sort of code page ?

The contents of the file do not matter; just use ".once test.csv", "select 'x';".


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] shell: .import: no special characters in table name

Clemens Ladisch
Clemens Ladisch wrote:

> Simon Slavin wrote:
>> On 19 Oct 2017, at 7:38pm, Clemens Ladisch wrote:
>>> the .import command does not work (and can show misleading error messages)
>>> if the table name contains special characters:
>>>
>>>  sqlite> .import test.csv temp.t
>>
>> What format is the file "temp.t" in ?  UTF-8 ?  ASCII ?  Some sort of code page ?
>
> The contents of the file do not matter; just use ".once test.csv", "select 'x';".

Sorry, I misread; "test.csv" is the file name, "temp.t" is the table name.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users