示例#1
0
from tables import Results, ResultsMov, ResultsTrack, ResultsArtist, ResultsActor, ResultsDirector

app = Flask(__name__)
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]:3306/ratemm'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SESSION_TYPE'] = 'filesystem'
app.secret_key = 'CMPT354PROJECT'
db = SQLAlchemy(app, use_native_unicode='utf8')

# relation
# many-many relation for act
acts = db.Table(
    'act',
    db.Column('movie_id',
              db.INTEGER(),
              db.ForeignKey('movie.id'),
              primary_key=True),
    db.Column('actor_id',
              db.INTEGER(),
              db.ForeignKey('actor.id'),
              primary_key=True))
# many-many relation for direct
directs = db.Table(
    'direct',
    db.Column('movie_id',
              db.INTEGER(),
              db.ForeignKey('movie.id'),
              primary_key=True),
    db.Column('director_id',
              db.INTEGER(),
示例#2
0
from flask_sqlalchemy import SQLAlchemy

# Initialize database.
db = SQLAlchemy()

# This is a postgis built-in table that we need to define, or else Alembic will try
# to remove it during every database migration.
spatial_ref_sys = db.Table(
    "spatial_ref_sys",
    db.Column("srid", db.INTEGER(), autoincrement=False, nullable=False),
    db.Column("auth_name",
              db.VARCHAR(length=256),
              autoincrement=False,
              nullable=True),
    db.Column("auth_srid", db.INTEGER(), autoincrement=False, nullable=True),
    db.Column("srtext",
              db.VARCHAR(length=2048),
              autoincrement=False,
              nullable=True),
    db.Column("proj4text",
              db.VARCHAR(length=2048),
              autoincrement=False,
              nullable=True),
    db.CheckConstraint("(srid > 0) AND (srid <= 998999)",
                       name="spatial_ref_sys_srid_check"),
    db.PrimaryKeyConstraint("srid", name="spatial_ref_sys_pkey"),
)