importing a database
Posted: Thu Apr 06, 2006 2:35 am
Basically I have a pretty large database (it's almost 50 megs when gzipped) that I need to import into another database on my local webserver.
Now, that'd be easy if it was just reading the dump and executing queries. But I need to write a script to transform the current database to fit the new database schema.
I've changed a lot of 'y' and 'n' s to 1s and 0s, omitted several fields, and changed field types on others. So I need to manipulate the information before I import the database.
Obviously the script will do this for me. But my question is, should I connect to the current database, do the operations, then close that connection, open the remote database connection and insert that value, then close it and open the local database again all inside of a loop?
Should I write the queries to a text file, then run that generated dump through mysql?
Now, that'd be easy if it was just reading the dump and executing queries. But I need to write a script to transform the current database to fit the new database schema.
I've changed a lot of 'y' and 'n' s to 1s and 0s, omitted several fields, and changed field types on others. So I need to manipulate the information before I import the database.
Obviously the script will do this for me. But my question is, should I connect to the current database, do the operations, then close that connection, open the remote database connection and insert that value, then close it and open the local database again all inside of a loop?
Should I write the queries to a text file, then run that generated dump through mysql?