Jake Gearhart
Jake Gearhart

Reputation: 307

choosing where to save sqlite database

This is probably a simple question, but I could use some help. I am trying to build a small database for an application that will only be run on my computer so I want to create a local database.

To do this I am trying to use sqlite. I can use the command prompt to make what seems to be a database by using the sqlite3 databaseName; functionality, but I do not know where it is being stored.

I need to be able to find the database to access it through the application I am experimenting with. I already know all of the basic sql and such for creating the database tables and data, but I cannot figure out how to simply make the database connection.

is there a way to specify where the database .db file will be stored, and why can I not find the file it seems to be making?

Upvotes: 3

Views: 10022

Answers (3)

LS_ᴅᴇᴠ
LS_ᴅᴇᴠ

Reputation: 11151

Using sqlite3 shell? Some help using sqlite3 -help:

Usage: sqlite3 [OPTIONS] FILENAME [SQL]

If FILENAME is not supplied, shell uses an temporary database.

If you start shell without supplying a filename, you may save temporary database at any time using:

sqlite> .backup MAIN "folder\your_file.extension"

Or you can ATTACH an existing database an use SQL methods:

sqlite> ATTACH DATABASE "path\stored.db" AS other;
sqlite> INSERT OR REPLACE INTO other.table1 SELECT * FROM this_table1;
sqlite> DETACH other;

Upvotes: 6

Jake Gearhart
Jake Gearhart

Reputation: 307

Thanks everyone for answering, but it turns out my issue was much simpler than I thought.

I was trying to name the database after already starting the shell.

I was supposed to create the database from command line by doing sqlite3 name.db

But I was trying to use that command within the sqlite shell so nothing was being created.

Upvotes: 0

ayon
ayon

Reputation: 2180

For doing such things , you can use Sqlite Manager , you'll get it as a Firefox addon. It's excellent in creating / Managing Sqlite database.

https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

Upvotes: 0

Related Questions