コード例 #1
0
ファイル: __init__.py プロジェクト: pooldin/pooldlib
def setup_package(self):
    config = dict()
    config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
    config['SQLALCHEMY_ECHO'] = SQLALCHEMY_ECHO
    config['SQLALCHEMY_RECORD_QUERIES'] = SQLALCHEMY_RECORD_QUERIES
    config['DEBUG'] = DEBUG
    db.init_connection(config)
    db.drop_all()
    db.create_all()
    create_fixtures()
コード例 #2
0
ファイル: install.py プロジェクト: pooldin/pooldb
    def default(self):
        connection = self.pargs.connection

        db.init_connection({
            'SQLALCHEMY_DATABASE_URI': connection,
            'SQLALCHEMY_ECHO': True
        })

        try:
            schema = self.pargs.schema

            drop = 'DROP SCHEMA IF EXISTS "%s" CASCADE;'
            drop %= schema

            db.session.execute(drop)
            db.session.execute('CREATE SCHEMA "%s";' % schema)
            db.session.execute('SET search_path TO "%s";' % schema)
            db.session.execute(self.sql())
            db.session.commit()
        finally:
            db.session.remove()
コード例 #3
0
ファイル: install.py プロジェクト: pooldin/pooldb
    def default(self):
        connection = self.pargs.connection

        db.init_connection({
            'SQLALCHEMY_DATABASE_URI': connection,
            'SQLALCHEMY_ECHO': True
        })

        try:
            schema = self.pargs.schema

            drop = 'DROP SCHEMA IF EXISTS "%s" CASCADE;'
            drop %= schema

            db.session.execute(drop)
            db.session.execute('CREATE SCHEMA "%s";' % schema)
            db.session.execute('SET search_path TO "%s";' % schema)
            db.session.execute(self.sql())
            db.session.commit()
        finally:
            db.session.remove()
コード例 #4
0
ファイル: install.py プロジェクト: pooldin/pooldb
    def default(self):
        if self.pargs.list:
            self.list_migrations()
            return
        if not self.pargs.migration:
            print "Please select either --list or --migration <migration name>"
            return

        connection = self.pargs.connection

        db.init_connection({
            'SQLALCHEMY_DATABASE_URI': connection,
            'SQLALCHEMY_ECHO': True
        })

        try:
            schema = self.pargs.schema
            db.session.execute('SET search_path TO "%s";' % schema)
            db.session.execute(self.migration(self.pargs.migration))
            db.session.commit()
        finally:
            db.session.remove()
コード例 #5
0
ファイル: install.py プロジェクト: pooldin/pooldb
    def default(self):
        if self.pargs.list:
            self.list_migrations()
            return
        if not self.pargs.migration:
            print "Please select either --list or --migration <migration name>"
            return

        connection = self.pargs.connection

        db.init_connection({
            'SQLALCHEMY_DATABASE_URI': connection,
            'SQLALCHEMY_ECHO': True
        })

        try:
            schema = self.pargs.schema
            db.session.execute('SET search_path TO "%s";' % schema)
            db.session.execute(self.migration(self.pargs.migration))
            db.session.commit()
        finally:
            db.session.remove()
コード例 #6
0
ファイル: __init__.py プロジェクト: pooldin/pooldwww
def init_database(app):
    db.init_connection(app.config)
    app.teardown_appcontext(lambda r: db.session.remove())
コード例 #7
0
def init_database(app):
    db.init_connection(app.config)
    app.teardown_appcontext(lambda r: db.session.remove())
コード例 #8
0
ファイル: __init__.py プロジェクト: pooldin/pooldrest
DIR = os.path.dirname(__file__)
DIR = os.path.abspath(DIR)

settings = os.environ.get('POOLDREST_CONFIG')
settings = settings or 'pooldrest.settings.dev'

# Create app
app = Flask(__name__)

# Configure the app
app.config.from_object('pooldrest.settings.base')
app.config.from_object(settings)

# Initialize database
db.init_connection(app.config)

# TODO: Register all application blueprint


# Rollback any pending transaction, close any open cursors and close any
# open connections when the application is torn down.
@app.teardown_appcontext
def shutdown_session(response):
    db.session.remove()


@app.route('/')
def index():
    return 'Hello World!'