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

35 views
Skip to first unread message

Fahim Patel

unread,
Nov 7, 2012, 6:50:29 AM11/7/12
to rubyonra...@googlegroups.com


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

Fahim Patel

unread,
Nov 7, 2012, 6:53:35 AM11/7/12
to rubyonra...@googlegroups.com
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 ? 

Colin Law

unread,
Nov 7, 2012, 7:16:56 AM11/7/12
to rubyonra...@googlegroups.com
On 7 November 2012 11:50, Fahim Patel <paf...@gmail.com> wrote:
>
>
> 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 ?

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

>
> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/EtBsbS4cArwJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Colin Law

unread,
Nov 7, 2012, 7:17:43 AM11/7/12
to rubyonra...@googlegroups.com
man sqlite3 should show you.

Colin

Fahim Patel

unread,
Nov 7, 2012, 7:35:56 AM11/7/12
to rubyonra...@googlegroups.com
I do lots of google but i get nothing. 

Colin

Fabian Becker

unread,
Nov 7, 2012, 8:30:10 AM11/7/12
to rubyonra...@googlegroups.com

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. 


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

Type ".help" inside the SQLite3 shell to learn more.

saikiran mothe

unread,
Nov 7, 2012, 8:35:45 AM11/7/12
to rubyonra...@googlegroups.com
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




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.

Colin Law

unread,
Nov 7, 2012, 8:35:39 AM11/7/12
to rubyonra...@googlegroups.com
It is probably easiest just to exit sqlite3 and start it again on the other db.

Colin

>>
>>
>> Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/e0aJtuY7Jq0J.

saikiran mothe

unread,
Nov 7, 2012, 8:37:17 AM11/7/12
to rubyonra...@googlegroups.com
$ cd yourapp/db

$ sqlite3 develoment.sqlite3

$ .help

$ .databases

$ .use databasename

$ .tables

Hassan Schroeder

unread,
Nov 7, 2012, 8:37:55 AM11/7/12
to rubyonra...@googlegroups.com
On Wed, Nov 7, 2012 at 5:30 AM, Fabian Becker <fabian....@gmail.com> wrote:

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

Well, not necessarily; see the ATTACH command.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

saikiran mothe

unread,
Nov 7, 2012, 8:39:31 AM11/7/12
to rubyonra...@googlegroups.com
Fabian,

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

Thanks,
Saikiran Mothe

Fahim Patel

unread,
Nov 7, 2012, 8:52:44 AM11/7/12
to rubyonra...@googlegroups.com
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 

saikiran mothe

unread,
Nov 7, 2012, 8:57:28 AM11/7/12
to rubyonra...@googlegroups.com
$sqlite3 develoment.sqlite3

use .sqlite3



On Wed, Nov 7, 2012 at 7:00 PM, Fabian Becker <fabian....@gmail.com> wrote:

--

Hassan Schroeder

unread,
Nov 7, 2012, 8:59:49 AM11/7/12
to rubyonra...@googlegroups.com
On Wed, Nov 7, 2012 at 5:52 AM, Fahim Patel <paf...@gmail.com> 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

Fahim Patel

unread,
Nov 7, 2012, 9:15:16 AM11/7/12
to rubyonra...@googlegroups.com


On Wednesday, November 7, 2012 7:31:58 PM UTC+5:30, Hassan Schroeder wrote:
On Wed, Nov 7, 2012 at 5:52 AM, Fahim Patel <paf...@gmail.com> 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

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.

Hassan Schroeder

unread,
Nov 7, 2012, 9:24:00 AM11/7/12
to rubyonra...@googlegroups.com
On Wed, Nov 7, 2012 at 6:15 AM, Fahim Patel <paf...@gmail.com> wrote:

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

> 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.

Fahim Patel

unread,
Nov 7, 2012, 10:41:02 AM11/7/12
to rubyonra...@googlegroups.com


On Wednesday, November 7, 2012 7:55:25 PM UTC+5:30, Hassan Schroeder wrote:
On Wed, Nov 7, 2012 at 6:15 AM, Fahim Patel <paf...@gmail.com> wrote:

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

> 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.

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 ?

Hassan Schroeder

unread,
Nov 7, 2012, 11:28:33 AM11/7/12
to rubyonra...@googlegroups.com
On Wed, Nov 7, 2012 at 7:41 AM, Fahim Patel <paf...@gmail.com> wrote:

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

I would think attaching the same db under a different name wouldn't
be a great idea :-)

In any case, "name" and "file" seem pretty obvious; don't really know
any use for "seq" offhand.
Reply all
Reply to author
Forward
0 new messages