8

I am struggling to create a database using SQLite3 using Windows 7.

SLite3 is currently installed:

C:\Program Files (x86)\Development\

and has sqlite3.def, sqlite3.dll and a sqlite3 (.exe) file.

I have also updated the environment variable of Path to:

C:\Program Files (x86)\Development\

When I double click:

sqlite3.exe

It opens up the command prompt with the address at the top as:

C:\Program Files (x86)\Development\sqlite3.exe

It opens up and is:

"Connected to a transient in-memory database."
(transient in-memory database) is in red text

Looking around this means that it saves to memory and not hard disk but if you specify:

.save testDB

Then all should be good, but not for me. I have tried:

sqlite3 testDB.db
.save testDB
create table tbl1(one varchar(10), two smallint);

But I get the error:

Error: near "sqlite3" syntax error

Any ideas what I'm doing wrong? I have SQLite manager installed too but I assume I can't use that until a database is saved to disk?

Thanks.

Would changing my Path variable to:

C: \Program Files (x86)\Development\

Make any difference i.e. a space between : and the \?

1
  • goto the link point number 2. sqlite.org/cli.html Commented Apr 16, 2018 at 21:05

5 Answers 5

8

I ran into the same problem and found help here on the official website. Essentially, you can double-click on the sqlite3.exe file. Then use the .open command to get a persistent database. To create your testDB.db database, you can do as follows:

SQLite version 3.8.8.3 2015-02-25 13:29:11
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open c:/sqlite/testDB.db
sqlite>

This should create testDB.db in c:/sqlite or some other folder you specify.

Sign up to request clarification or add additional context in comments.

1 Comment

It did not work for me in Ubuntu 22: sqlite> .open ~/db.db Error: unable to open database "~/db.db": unable to open database file . >sqlite3 db.db did.
1
  1. You do not need sqlite3.def or sqlite3.dll.
  2. There are two ways if starting the sqlite3 command-line shell, either by double-clicking on the .exe, or by typing sqlite3 and any parameters in the Command Prompt. Do not try to start sqlite3 from inside itself.
  3. SQLite Manager is able to create a new database.
  4. Using a wrong path would not work.

Comments

1

Reach the path where you want to start with SQLite through command prompt, for e.g. c:\sqlite>. Now when I use ls command I get
c:\sqlite>ls
sqlite3.exe
Now to create database type
c:\sqlite>sqlite3 database.db
It will create a database for you.

Comments

0
  1. Add sqlite3.exe in a folder, for example: C:\sqlite3\sqlite3.exe
  2. Now go to the path where the sqlite3.exe is and run it.

Comments

0

Per the '.help' instructions, type '.save filename'. When reopening, type '.open filename'. This worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.