sqlchemy self made

Posted CrossPython

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlchemy self made相关的知识,希望对你有一定的参考价值。

# -*- coding: utf-8 -*-
from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, Table,Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship

DB_URI = "mysql+pymysql://root:[email protected]:3306/xiachufang2"
engine = create_engine(DB_URI)
Base = declarative_base(engine)
session = sessionmaker(engine)()

class Recipe_Mat(Base):
    __tablename__ = ‘recipe_mat‘
    material_id = Column(Integer, ForeignKey(‘material.id‘),primary_key=True)
    food_id = Column(Integer, ForeignKey(‘food.id‘),primary_key=True)

class Recipe(Base):
    __tablename__=‘food‘
    id=Column(Integer,autoincrement=True,primary_key=True)
    food=Column(String(128),nullable=False)
    step=Column(Text)
    tip=Column(Text)
    description=Column(Text)
    materials=relationship(‘Material‘,secondary=‘recipe_mat‘)


class Material(Base):
    __tablename__ = ‘material‘
    id = Column(Integer, autoincrement=True, primary_key=True)
    material = Column(String(128), nullable=False)
    volume=Column(String(128))
    foods = relationship(‘Recipe‘, secondary=‘recipe_mat‘)

  

以上是关于sqlchemy self made的主要内容,如果未能解决你的问题,请参考以下文章

在fink(vs self-made)mySQL安装上安装mySQL gem

db2+python+sqlchemy环境的搭建

第二次通话失败

make-made-made的区别

将统一值传递给顶点和片段着色器

python基础===pendulum '''Python datetimes made easy.'''