AndrewNR
AndrewNR

Reputation: 164

Creating sqlite3 files/database

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 \?

Upvotes: 8

Views: 17719

Answers (5)

Gavin V
Gavin V

Reputation: 1

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

Upvotes: 0

Jonathan Freitas
Jonathan Freitas

Reputation: 61

  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.

Upvotes: 0

Sumit Nautiyal
Sumit Nautiyal

Reputation: 77

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.

Upvotes: 1

sedeh
sedeh

Reputation: 7313

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.

Upvotes: 8

CL.
CL.

Reputation: 180240

  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.

Upvotes: 1

Related Questions