Python3 代码:
# -*- coding: utf-8 -*-
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from datetime import datetime
import config
import os
basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = config.DB_URI
#mysql://root:[email protected]:3306/survey?charset=utf8
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app,use_native_unicode='utf8')
class Role(db.Model):
__tablename__ = 'roles'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), unique=True)
def __repr__(self):
return '<Role %r>' % self.name
print(config.DB_URI)
print(Role.query.all())
mysql status:
roles sql :
error:
lz 试了能搜到的办法,实在不知哪错了才问的 顺便请教各位一下 有没有好的 flask mysql python3 的 docker ?
1
haozibi 2016-05-18 08:25:55 +08:00 via Android
mysql+pymysql://xxxxxxx
|
2
jixiangqd 2016-05-18 10:09:03 +08:00
怎么感觉像 python2 的阵痛。。。真的是 python3 代码?
|