Python 3.x 如何使用docker创建peewee和mysql?

Python 3.x 如何使用docker创建peewee和mysql?,python-3.x,docker,mysql-connector,peewee,Python 3.x,Docker,Mysql Connector,Peewee,我试图使用Docker连接到Mysql数据库,但出现以下错误: peewee.ImproperlyConfigured: MySQL driver not installed! 这是我的文件 FROM python:3.7 ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY . /app RUN pip install peewee RUN python create_db.py 这是我的docker-compose.yml version: '3.3'

我试图使用Docker连接到Mysql数据库,但出现以下错误:

peewee.ImproperlyConfigured: MySQL driver not installed!
这是我的文件

FROM python:3.7
ENV PYTHONUNBUFFERED 1

WORKDIR /app

COPY . /app

RUN pip install peewee
RUN python create_db.py
这是我的docker-compose.yml

version: '3.3'

services:

    app-mariadb:
        image: mariadb:10.4     
        container_name: app-mariadb                
        ports:
            - "3320:3306"
        environment:
            MYSQL_ROOT_PASSWORD: helloWORLD123
            MYSQL_DATABASE: sp_odesi
            MYSQL_USER: root
            MYSQL_PASSWORD: helloWORLD123

    app-python:
        build: .        
        container_name: app-python      
        command: python create_db.py
        restart: always        
        working_dir: /app
        depends_on:
            - app-mariadb
        volumes:
            - ./:/app
        environment:
            MYSQL_HOST: db
            MYSQL_DATABASE: sp_odesi
            MYSQL_USER: root
            MYSQL_PASSWORD: helloWORLD123
            MYSQL_PORT: 3306
            DATABASE: MARIADB
创建_db.py

from peewee import *
from datetime import datetime
import os


db = MySQLDatabase(
        "sp_odesi",user="root",
        passwd="helloWORLD123",port=3306
    )

class Surveys(Model):
    """Surveys

    """
    survey_name     = CharField(max_length=100, unique=True, null=False)

    class Meta:
        database = db

if __name__ == '__main__':
    Surveys.create_table()
    print("Create table")
你。将Dockerfile中的以下行从更改为

RUN pip install peewee PyMySQL

你。将Dockerfile中的以下行从更改为

RUN pip install peewee PyMySQL