Usage: .read FILE - Read file doseont work
(1) By Gaël (Gael4429) on 2022-05-30 14:53:05 [link] [source]
Hi,
I just started with SQLITE.
I made a table with import
now I try to made a other small table with read a SQL file.
I try with read but it didnt work.
if I try : sqlite> .read Source.sql
I have as result : Error: cannot open "Source.sql"
if I try : sqlite> .read "C:UsersGaelDocumentsProjet - SQLSource.sql"
I have as result : Usage: .read FILE
That mean, SQLite do not understand nothing.
Did you know how to do this ? I'm looking for in Internet and nothing is explain on this small aspect...
thanks for attentions
(2) By Keith Medcalf (kmedcalf) on 2022-05-30 18:19:33 in reply to 1 [link] [source]
if I try : sqlite> .read Source.sql
I have as result : Error: cannot open "Source.sql"
This means that the file Source.sql
was not found in the current directory. Since it appears that you are using Windows (based on your attempted use of DOS style pathnames) you can find out what the current directory
contains by issuing the command: .system dir
.
f I try : sqlite> .read "C:UsersGaelDocumentsProjet - SQLSource.sql"
I have as result : Usage: .read FILE
You seem to have forgotten that you need to escape your escape character if you use them as path separators. Furthermore, if your "filename" (or path segment) contains delimiters (eg, space), then you must put the filename in quotes.
If you wish to use the fullpath then you must specify the filename correctly. Any of the following is a correct DOS-style path:
.read "C:\\Users\\Gael\\DocumentsProjet - SQL\\Source.sql"
.read 'C:\\Users\\Gael\\DocumentsProjet - SQL\\Source.sql'
.read "C:/Users/Gael/DocumentsProjet - SQL/Source.sql"
.read 'C:/Users/Gael/DocumentsProjet - SQL/Source.sql"
It would probably be perspicacious, however, to simply execute the sqlite3 executable so that the current directory
is correct, then you do not need to fiddle about with path specifications.
(3.1) By midijohnny on 2022-05-30 18:22:09 edited from 3.0 in reply to 1 [link] [source]
Are you sure you started 'sqlite3' in the same directory as the file 'Source.sql'?
Maybe try this:
.header off
.once test.sql
VALUES('SELECT 1');
.read test.sql
This will write out a file - which contains some SQL - then read it back in again. Assuming you can write to the file 'test.sql', this should work.
What's the point of the experiment? Once you have confirmed that you are able to write and then read 'test.sql' - make sure you file 'Source.sql' exists in the same directory.
(4) By Larry Brasfield (larrybr) on 2022-05-30 18:34:18 in reply to 1 [link] [source]
if I try : sqlite> .read "C:\Users\Gael\Documents\Projet - SQL\Source.sql"
I have as result : Usage: .read FILE
When I try the same, I get:
Error: cannot open "C:UsersGaelDocumentsProjet - SQLSource.sql"
This is as I expect because the single, double-quoted argument to .read has backslash de-escaping applied before it is given to the .read command.
That mean, SQLite do not understand nothing.
Are double-negatives used commonly in your native language? To the extent that a program can be sensibly said to understand anything, it is true that SQLite understands more than nothing. Yet I doubt you intended to affirm this.
Try using single-quote characters around your .read argument. This will prevent the backslashes from being interpreted by the argument parser.1 And take care that your 'Source.sql' file is in a subdirectory named 'Projet', or correct the spelling of that subdirectory name.
In the future, show what you submitted to the CLI, formatted per the markdown rules, so that others can see what is not working for you.
(5) By Gaël (Gael4429) on 2022-06-02 09:53:58 in reply to 4 [source]
Thanks all.
It's a problem a folder. You're rigth !!
then I used thoses commands : To know the current folder : .system dir To change the folder : .cd <REPERTOIRE>
Be carefull with <REPERTOIRE>, if ther is some spaces in it, you have to use quotes (") and to print 2 for one. It's give something like : .cd "c:\Chemin\My folder\"
Thanks all for helpiing me.
an sorry for my englich if not so good.