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.
on 2009-05-20 19:40
on 2009-05-21 22: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
on 2009-05-21 23: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