Sqlite3 is confused me fully What to give database extension (.db or .sqlite3)?

Hi all ,

I have create new application in rails with sqlite3 .
Its totally confusing to me when i see my database.yml file.
Reason of confusing is what type of extension is given to database ?

I have knowledge that by executing following line will create database
:-
sqlite3 test.db
See the extension of database is .db

But when i see my database.yml , extension of database is .sqlite3
database.yml is copied below.
What is extension of database in sqlite3 ?

In my database.yml file
SQLite version 3.x

gem install sqlite3

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

Warning: The database defined as “test” will be erased and

re-generated from your development database when you run “rake”.

Do not set this db to the same as development or production.

test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Thanks

Best Regards
Fahim Babar Patel

On Wednesday, November 7, 2012 5:20:29 PM UTC+5:30, Fahim P. wrote:

      sqlite3 test.db

adapter: sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

One more question how to switch database in Sqlite3.
In mysql we fire
use database_name
In postgre we fire
\c database_name
But what to fire in sqlite3 ?

On 7 November 2012 11:50, Fahim P. [email protected] wrote:

See the extension of database is .db

But when i see my database.yml , extension of database is .sqlite3
database.yml is copied below.
What is extension of database in sqlite3 ?

You can use any extension you like. It is just a file.

On 7 November 2012 11:53, Fahim P. [email protected] wrote:

Reason of confusing is what type of extension is given to database ?
SQLite version 3.x
test:

One more question how to switch database in Sqlite3.
In mysql we fire
use database_name
In postgre we fire
\c database_name
But what to fire in sqlite3 ?

man sqlite3 should show you.

Colin

On Wednesday, November 7, 2012 5:48:38 PM UTC+5:30, Colin L. wrote:

database.yml is copied below.

adapter: sqlite3
\c database_name
But what to fire in sqlite3 ?

man sqlite3 should show you.

One more question how to switch database in Sqlite3.
In mysql we fire
use database_name
In postgre we fire
\c database_name
But what to fire in sqlite3 ?
I do lots of google but i get nothing.

On 7 November 2012 12:35, Fahim P. [email protected] wrote:

pool: 5

use database_name

In postgre we fire
\c database_name
But what to fire in sqlite3 ?
I do lots of google but i get nothing.

It is probably easiest just to exit sqlite3 and start it again on the
other db.

Colin

You only have a single database in SQLite3, there is no need to select
one.

Type “.help” inside the SQLite3 shell to learn more.

Hi Fabian,

Go to yourapp/db

then you will see development.sqlite3 and test.sqlite3

Run
– sqlite3 development.sqlite3

– .databases

– .help

—.tables

check .help command you will know more commands on sqlite3

Thanks,
Saikiran Mothe

$ cd yourapp/db

$ sqlite3 develoment.sqlite3

$ .help

$ .databases

$ .use databasename

$ .tables

Fabian,

You can Sqlite3 for development purpose,Its a lightweight database.for
production you need to switch to postgresql,mysql,mongo.

Thanks,
Saikiran Mothe

On Wed, Nov 7, 2012 at 5:30 AM, Fabian Becker
[email protected] wrote:

You only have a single database in SQLite3, there is no need to select one.

Well, not necessarily; see the ATTACH command.


Hassan S. ------------------------ [email protected]

twitter: @hassan

$sqlite3 develoment.sqlite3

use .sqlite3

On Wednesday, November 7, 2012 7:10:23 PM UTC+5:30, sai kiran mothe
wrote:

On Wed, Nov 7, 2012 at 7:07 PM, saikiran mothe
<[email protected]<javascript:>

$ .use databasename

On Wed, Nov 7, 2012 at 7:00 PM, Fabian Becker
<[email protected]<javascript:>

You only have a single database in SQLite3, there is no need to select
one.

Type “.help” inside the SQLite3 shell to learn more.

So over all which i understood is that in Sqlite we can use only one
database at a time.

Is above statement is correct.

Thanks

Best Regards to All
Fahim Babar Patel

On Wed, Nov 7, 2012 at 5:52 AM, Fahim P. [email protected] wrote:

So over all which i understood is that in Sqlite we can use only one
database at a time.

Is above statement is correct.

No. Again, see the ATTACH command:
http://www.sqlite.org/lang_attach.html


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Wednesday, November 7, 2012 7:31:58 PM UTC+5:30, Hassan S.
wrote:

Attach database is different concept which you are saying ?

My question was

In mysql we fire below command
use database_name
In postgre we fire below command
\c database_name
But what to fire in sqlite3 to switch database?

@colin has given the answer is that you have exit open another database.

Waiting for your reply
Hope you will understood.

On Wed, Nov 7, 2012 at 6:15 AM, Fahim P. [email protected] wrote:

No. Again, see the ATTACH command: ATTACH DATABASE

My question was

But what to fire in sqlite3 to switch database?

If you read the page I referred to, you’ll see that you don’t “switch”
databases, you refer to the attached one(s) explicitly by name.


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Wednesday, November 7, 2012 7:55:25 PM UTC+5:30, Hassan S.
wrote:

If you read the page I referred to, you’ll see that you don’t “switch”
databases, you refer to the attached one(s) explicitly by name.

It works …

I attach development database to test.
###################################
attach development as test;
sqlite> .databases
seq name file



0 main /home/titainum9/development

2 test /home/titainum9/development
#######################################
but i am not understanding what that column “name” “seq” “file” means ?

On Wed, Nov 7, 2012 at 7:41 AM, Fahim P. [email protected] wrote:

but i am not understanding what that column “name” “seq” “file” means ?
I would think attaching the same db under a different name wouldn’t
be a great idea :slight_smile:

In any case, “name” and “file” seem pretty obvious; don’t really know
any use for “seq” offhand.


Hassan S. ------------------------ [email protected]

twitter: @hassan