May create a new MySQL database

I looked through all the documents I could find and read the source code ... and it looks like you cannot create a MySQL database (or any other kind that I could find) using peewee. If so, that means that for any database that I can connect to, I will need to create it manually using mysql or another tool.

Is this accurate, or am I missing something?

+6
source share
3 answers

Peewee can create tables, but not databases. This is the standard for ORM, since creating databases is very vendor specific and is usually considered a very administrative task. PostgreSQL requires you to connect to a specific database, Oracle mixes the differences between users and databases, SQLite believes that each file is a database ... it is very specific to the environment.

+8
source

Peewee cannot create databases with MySql or with other systems that require database and user settings, but will create a database with sqlite when creating the first table.

+2
source

You cannot create a MySQL database with peewee, but you can do it programmatically with other libraries, such as PyMySQL .

 import pymysql conn = pymysql.connect(host='host', user='user', password='password') conn.cursor().execute('CREATE DATABASE mydb') conn.close() 
0
source

Source: https://habr.com/ru/post/973517/


All Articles