search

Home  >  Q&A  >  body text

Flask项目里面,如何同时使用MySQL和MongoDB,Sqlalchemy和MongoEngine?

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)
黄舟黄舟2800 days ago859

reply all(2)I'll reply

  • 某草草

    某草草2017-04-24 16:01:37

    The two databases cannot reference each other. Do it manually. Write a property for Page, such as get_user or something.

    reply
    0
  • 習慣沉默

    習慣沉默2017-04-24 16:01:37

    Isn’t it okay to put the functions in different packages?

    reply
    0
  • Cancelreply