示例#1
0
# -*- coding: utf-8 -*-

from sqlalchemy import *
import transaction
#from sqlalchemy.ext.declarative import declarative_base
#from sqlalchemy.orm import relation, backref, synonym, sessionmaker
#from sqlalchemy import types, sql, Table, ForeignKey, Column, CheckConstraint, DefaultClause, UniqueConstraint
#from miweb import model #import init_model
from nitrogym.model import DeclarativeBase, metadata, DBSession, init_model
#from sqlalchemy.exc.IntegrityError.params


#from sqlalchemy.sql.alias()

engine = create_engine('postgresql://*****:*****@127.0.0.1:5432/nitrogym', echo=True)
init_model(engine)



#
#def session_commit():
#    transaction.commit()
    
    
#DeclarativeBase = declarative_base(engine)
#metadata = DeclarativeBase.metadata
#Session = sessionmaker(engine)
#DBSession = Session()


示例#2
0
def setup_db():
    """Method used to build a database"""
    engine = config['pylons.app_globals'].sa_engine 
    model.init_model(engine)
    model.metadata.create_all(engine)