Forum: Ruby on Rails Sqlite3 is confused me fully What to give database extension (.db or .sqlite3)?

Posted by fahim patel (fahim_patel)
on 2012-11-07 12:51
(Received via mailing list)
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
Posted by fahim patel (fahim_patel)
on 2012-11-07 12:54
(Received via mailing list)
On Wednesday, November 7, 2012 5:20:29 PM UTC+5:30, Fahim Patel 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 ?
Posted by Colin Law (Guest)
on 2012-11-07 13:18
(Received via mailing list)
On 7 November 2012 11:50, Fahim Patel <pafahim@gmail.com> 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.
Posted by Colin Law (Guest)
on 2012-11-07 13:19
(Received via mailing list)
On 7 November 2012 11:53, Fahim Patel <pafahim@gmail.com> 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
Posted by fahim patel (fahim_patel)
on 2012-11-07 13:37
(Received via mailing list)
On Wednesday, November 7, 2012 5:48:38 PM UTC+5:30, Colin Law 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.
Posted by Fabian Becker (Guest)
on 2012-11-07 14:31
(Received via mailing list)
>>
>>
You only have a single database in SQLite3, there is no need to select 
one.

Type ".help" inside the SQLite3 shell to learn more.
Posted by Colin Law (Guest)
on 2012-11-07 14:37
(Received via mailing list)
On 7 November 2012 12:35, Fahim Patel <pafahim@gmail.com> 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
Posted by Saikiran Mothe (saikiranmothe)
on 2012-11-07 14:37
(Received via mailing list)
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
Posted by Saikiran Mothe (saikiranmothe)
on 2012-11-07 14:38
(Received via mailing list)
$ cd yourapp/db

$ sqlite3 develoment.sqlite3

$ .help

$ .databases

$ .use databasename

$ .tables
Posted by Hassan Schroeder (Guest)
on 2012-11-07 14:39
(Received via mailing list)
On Wed, Nov 7, 2012 at 5:30 AM, Fabian Becker 
<fabian.becker87@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.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Posted by Saikiran Mothe (saikiranmothe)
on 2012-11-07 14:41
(Received via mailing list)
Fabian,

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

Thanks,
Saikiran Mothe
Posted by fahim patel (fahim_patel)
on 2012-11-07 14:53
(Received via mailing list)
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 
<saikira...@gmail.com<javascript:>
>> $ .use databasename
>>>
>>>
>>> On Wed, Nov 7, 2012 at 7:00 PM, Fabian Becker 
<fabian....@gmail.com<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
Posted by Saikiran Mothe (saikiranmothe)
on 2012-11-07 14:58
(Received via mailing list)
$sqlite3 develoment.sqlite3

use .sqlite3
Posted by Hassan Schroeder (Guest)
on 2012-11-07 15:02
(Received via mailing list)
On Wed, Nov 7, 2012 at 5:52 AM, Fahim Patel <pafahim@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

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Posted by fahim patel (fahim_patel)
on 2012-11-07 15:16
(Received via mailing list)
On Wednesday, November 7, 2012 7:31:58 PM UTC+5:30, Hassan Schroeder 
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.
Posted by Hassan Schroeder (Guest)
on 2012-11-07 15:25
(Received via mailing list)
On Wed, Nov 7, 2012 at 6:15 AM, Fahim Patel <pafahim@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.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Posted by fahim patel (fahim_patel)
on 2012-11-07 16:42
(Received via mailing list)
On Wednesday, November 7, 2012 7:55:25 PM UTC+5:30, Hassan Schroeder 
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 ?
Posted by Hassan Schroeder (Guest)
on 2012-11-07 17:29
(Received via mailing list)
On Wed, Nov 7, 2012 at 7:41 AM, Fahim Patel <pafahim@gmail.com> 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 :-)

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

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.