user984621
user984621

Reputation: 48453

How to completely clean SQLite3 database and import fresh data?

I have a dump data from our production SQLite3 database. On the localhost there's a local SQLite3 database for the respective project. I need to import the dump of the database from production to the local database.

How do I do that? Do I need to remove the local SQLite3 database, or, if I run the import of the SQLite3 database from production, will the production data overwrite the records in the local database?

It's a database for a Rails app.

Upvotes: 0

Views: 398

Answers (2)

the Tin Man
the Tin Man

Reputation: 160551

I'd recommend getting in the habit of either truncating the table, or dropping it and recreating it, prior to loading the data. If/when you move from SQLite to a DBM like MySQL or PostgreSQL, you'll find that same technique will work well.

See "Truncate a SQLite table if it exists?" for more information.

Upvotes: 0

spickermann
spickermann

Reputation: 106952

SQLite databases are just flat files. You can just download the the database file from your server. You find it here: #{Rails.root}/db/production.sqlite3. Than replace your local development database file at #{Rails.root}/db/development.sqlite3 with the downloaded file.

Upvotes: 1

Related Questions