# Migrating from SQLite to MySql or Postgres using peewee

**URL:** <https://support.prodi.gy/t/migrating-from-sqlite-to-mysql-or-postgres-using-peewee/3527>\
**Category:** Uncategorized\
**Tags:** database, project\
**Created:** [October 14, 2020, 8:51pm UTC](https://support.prodi.gy/t/migrating-from-sqlite-to-mysql-or-postgres-using-peewee/3527 "2020-10-14T20:51:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrGabrielHarris](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/drgabrielharris/32/1679_2.png) [@DrGabrielHarris](https://support.prodi.gy/u/DrGabrielHarris)\
**Post date:** [October 14, 2020, 8:51pm UTC](https://support.prodi.gy/t/migrating-from-sqlite-to-mysql-or-postgres-using-peewee/3527/1 "2020-10-14T20:51:57Z")

</div>

I've recently wrote a [Medium article](https://medium.com/@DrGabrielHarris/python-how-migrate-prodigy-database-to-mysql-or-postgres-e755079f5f58) about migrating the default Sqlite schema to a Mysql or Postgres sever database and I thought I share a code snippet here for others to check!

```
from peewee import MySQLDatabase, SqliteDatabase
from playhouse.reflection import Introspector

sqlite_db = SqliteDatabase("prodigy.db")
introspector = Introspector.from_database(sqlite_db)
models = introspector.generate_models()

mysql_db = MySQLDatabase(
    user="user name",
    password="user password",
    host="host name",
    port=3306,
    database="database name",
)

mysql_db.create_tables(list(models.values()))
mysql_db.close()

```

Happy prodigy coding!

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [October 15, 2020, 9:29am UTC](https://support.prodi.gy/t/migrating-from-sqlite-to-mysql-or-postgres-using-peewee/3527/2 "2020-10-15T09:29:23Z")

</div>

Wow, thanks so much for sharing your code and the write-up 🙏 ✨ (Also glad to hear that the solution was pretty straightforward – especially on the scale of "database migrations" 😅)
