Creating sqlite3 files/database

12,411

Solution 1

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.

Solution 2

  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.
Share:
12,411

Related videos on Youtube

AndrewNR
Author by

AndrewNR

Currently studying a computer science degree with the OU. Complete it this year (2014).

Updated on September 15, 2022

Comments

  • AndrewNR
    AndrewNR about 1 year

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