My project is built in Python Django which I have set up on Digital Ocean Cloud but it has inbuilt DBSQLITE database, I want to connect mysql with my database, when I connected mysql and loaded the data, I got empty tables, the data did not come. Please tell me step by step steps
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey!
Are you using the DigitalOcean App Platform? If this is the case, the best approach here would be to use a managed MySQL cluster.
Using SQLite with the App Platform is not recommended as the App Platform has ephemeral storage, meaning that any data you store on the App Platform itself locally, will be lost after each redeployment.
To set up MySQL in your Python Django project on DigitalOcean, and resolve the issue of empty tables when migrating, follow these steps:
Create a MySQL Cluster:
Install Django MySQL Adapter:
Update
settings.py
: Open your Django project’ssettings.py
file and update theDATABASES
setting:Replace
your_database_name
,your_mysql_user
,your_mysql_password
,your_mysql_host
, andyour_mysql_port
with the details from your DigitalOcean Managed MySQL Database.After that redeploy your project to the App Platform.
Let me know how it goes!
Best,
Bobby
Heya @zappcodeacademy,
The data you have in your SQLLITE db will not automatically migrate over to the MySQL.
Yes, you can run your migrations to create the structure of your DB in MySQL however you’ll need to find another way to dump the data from your SQLLITE to MySQL.
Let’s first make sure you ahve the proper stuff in your settings.py file:
Migrate Your Existing Data