I've looked through all the docs I could find, and read the source code...and it doesn't seem you can actually create a MySQL database (or any other kind, that I could find) using peewee. If so, that means for any the database I may need to connect to, I would need to create it manually using mysql or some other tool.
Is that accurate, or am I missing something?
Peewee can create tables but not databases. That's standard for ORMs, as creating databases is very vendor-specific and generally considered a very administrative task. PostgreSQL requires you to connect to a specific database, Oracle muddles the distinction between users and databases, SQLite considers each file to be a database...it's very environment specific.
You can't create a MySQL database with peewee, but you can do it programatically with other libraries, for example with PyMySQL
.
import pymysql
conn = pymysql.connect(host='host', user='user', password='password')
conn.cursor().execute('CREATE DATABASE mydb')
conn.close()
Peewee cannot create databases with MySql or with other systems that require database and user setup, but will create the database with sqlite when the first table is created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With