How can I import an existing database to my db.py model?
-
I have successfully changed the default sqlite connection to mysql. Now I want to import an exported file (database.sql) which is an existing database. I need help on how I can do this please
-
Answer:
In a perfect world all you would need to do is dump your database to some file and import it in mysql. That is just open a mysql shell and execute the database.sql file... However, there can be some differences in the syntaxes of sqlite and mysql. In order to avoid these problems you can use a converter tool: http://www.sqlite.org/cvstrac/wiki?p=ConverterTools As far as I remember the asker uses web2py. I've never used this, but it seems that you can use its DAL to do the conversion as well: http://www.web2py.com/AlterEgo/default/show/196
Julius Bier Kirkegaard at Quora Visit the source
Other answers
first make your model match your db -- meaning column names and data types then add the following to you DAL fake_migrate=True so in my project it looks like so normal production modeĀ -- db = DAL(settings.production_database_uri, 5) I have messed with the db and want the project to sync to the db -- db = DAL(settings.production_database_uri, 5,fake_migrate=True) then restart the serverĀ once, remove the fake_migrate=True and restart the server again. at this point your db and model should be in sync
Isaac Jessop
Good that you were able to get mysql installed and configured it on web2py yourself! The new http://db.py just creates tables on mysql using the schema that you define on http://db.py. From there, it is just another table. Just move your rows from any other table or database using queries. (you can just google on how to export / import databases / tables in mysql for this)
Rajaram Srinivasan
Related Q & A:
- How can I restore Sharepoint web app when the DB is in another server?Best solution by SharePoint
- How can I import bookmarks from an old Yahoo account?Best solution by Yahoo! Answers
- How can I import a recording from GarageBand to iTunes?Best solution by Yahoo! Answers
- How can I import an address book from Outlook Express to my Yahoo! addresses?Best solution by uk.answers.yahoo.com
- How can I import my bookmarks from my yahoo browser?Best solution by productforums.google.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.