I feel like this is a stupid question because it seems like common sense . . . but no google search I can put together seems to be able to give me the answer!
I know how to get data OUT of a sqlite3 database using the .dump command. But now that I have this ASCII file titled export.sqlite3.sql . . . I can't seem to get it back INTO the database I want.
My goal was to transfer the data I had in one rails app to another so I didn't have to take all sorts of time creating dummy data again . . . so I dumped the data from my first app, got rid of all the CREATE TABLE statements, and made sure my schema on my second app matches . . . now I just have to get it IN there.
Would anyone mind helping me out? And when you find a way, will you tell me what you plugged into the google, 'cause I am beating my head open with a spoon right now over what I thought would be an easy find.
First, from the menu choose tool menu item. Second, choose the database and table that you want to import data then click the Next button. Third, choose CSV as the data source type, choose the CSV file in the Input file field, and choose the ,(comma) option as the Field separator as shown in the picture below.
One way to do it is to simply attach a new database using the backup file (or a copy of it). Another way to restore a database is to use the . restore dot command to restore the database file to your chosen database within SQLite CLI.
In SQLite Dump command is used to dump the databases, table's schema and tables data based on our requirements. By using SQLite Dump command we can save the structure and data of the database tables in SQL format to the disk.
cat dumpfile.sql | sqlite3 my_database.sqlite
This is modified from the sqlite3 getting started guide.
You didn't specify your operating system and while
sqlite3 my_database.sqlite < export.sqlite3.sql
will work for the unix flavors, it will not work for windows.
The inverse of the .dump command is the .read command. The syntax would be
sqlite3> .read export.sqlite3.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With