1
Peeweeに新しくなりました。私は同様の機能を持つ別のプロジェクトの後にコードをモデリングしています。しかし、私が抱えている問題は、テーブルを作成すると、sqlite DBが作成され、そこにテーブルがあることです。しかし、私はMySQLを使用しようとしています。Peeweeはmysqlの代わりにsqliteで表を作成します
関連するコード・ビット:
class MyRetryDB(RetryOperationalError, PooledMySQLDatabase):
pass
def init_database():
if args.db_type == 'mysql':
log.info('Connecting to MySQL database on %s:%i...',
args.db_host, args.db_port)
connections = args.db_max_connections
db = MyRetryDB(
args.db_name,
user=args.db_user,
password=args.db_pass,
host=args.db_host,
port=args.db_port,
max_connections=connections,
stale_timeout=300)
pprint.pprint(vars(db))
create_tables(db)
return db
def create_tables(db):
pprint.pprint(vars(db))
tables = [Table1, Table2]
db.connect()
for table in tables:
log.info("Creating table: %s", table.__name__)
db.create_tables([table], safe=True)
db.close()
私はこれで欠落している可能性があり、何かはありますか?