Forum: Ruby on Rails how to import db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-20 17:40
I'm just starting out learning.  So far, all I've done is little test
apps starting from scratch -- ie, ones in which rails creates an empty
database, then I make up some classes and views and controllers and
such. Nice system. But what if I have an SQlite database file created
elsewhere:  (how) can I import this into ruby "easily"?  I have not
tried yet because it just occurred to me that there is an id
field/column in the "native" rails databases.  Could I add such a column
and then just copy the db file straight into db/development.sqlite?

I am guessing the easiest way might be to just create an empty db with
all the necessary tables and columns and then write a script to copy the
relevant data in from the existing external db.
1ebcd34bbfe62169964bb9a5006de29f?d=identicon&s=25 Manasi V1 (manasi)
on 2009-05-21 20:39
Hi..
I have a similar system where my source db is legacy Oracle db. What I
have done is use MySQL db for development and Oracle in other
environments..You will need the schema for setting up local. Don't
import the db at one go.. Create migrations as you establish models and
associations for the app..
you can use SQL scripts if you want soem raw test data.

Thanks
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-21 21:00
Manasi V1 wrote:
> Hi..
> I have a similar system where my source db is legacy Oracle db. What I
> have done is use MySQL db for development and Oracle in other
> environments..You will need the schema for setting up local. Don't
> import the db at one go.. Create migrations as you establish models and
> associations for the app..
> you can use SQL scripts if you want soem raw test data.
>
> Thanks

Actually this was just for learning purposes.  I don't really want to
sit and manually add entries in a browser -- I'd like a decent size
database to play with while I get used to API.  So I'm writing a short
ruby script to collate some filesystem data into an sqlite3 file.  Which
shouldn't take much longer, hopefully everything will be okay.  If not I
will just pull the rails "development.sqlite3" file out and add to that
(I guess that's really what I should be doing...).  I'm using the same
fields as in the schema, plus "id", which AFAICT is just an int count
(1,2,3...).

So I was wondering if there are any caveats about this. (It's a
pre-emptive post; the next one will be "Whhaaa...Why won't the database
I made work in rails?")     ;)

MK
This topic is locked and can not be replied to.