Flask專案裡面,如何同時使用MySQL和MongoDB,Sqlalchemy和MongoEngine?
from mongoengine import *
import datetime
class Page(Document):
title = StringField(max_length=200, required=True)
date_modified = ateTimeField(default=datetime.datetime.now)
author = xxxx????【这里怎么关联到User呢?? 手工?】
=======
from sqlalchemy import Column, Integer, String
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
fullname = Column(String)
password = Column(String)
兩種資料庫,沒辦法互相引用。手動吧。給 Page 寫一個 property,像是 get_user 什麼的。
把函數放在不同的package裡不行?