当前位置: 首页>>代码示例>>Python>>正文


Python sqlalchemy_utils.drop_database函数代码示例

本文整理汇总了Python中sqlalchemy_utils.drop_database函数的典型用法代码示例。如果您正苦于以下问题:Python drop_database函数的具体用法?Python drop_database怎么用?Python drop_database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drop_database函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gen_engine

def gen_engine():

    _engine = create_db_test()

    yield _engine

    drop_database(url_db)
开发者ID:lffsantos,项目名称:captura,代码行数:7,代码来源:helper.py

示例2: stop_fixture

    def stop_fixture(self):
        """Clean up the config fixture and storage artifacts."""

        if hasattr(self, 'metricd_thread'):
            self.metricd_thread.stop()
            self.metricd_thread.join()

        if hasattr(self, 'fixtures'):
            for f in reversed(self.fixtures):
                f.cleanUp()

        if hasattr(self, 'index'):
            self.index.disconnect()

        # Swallow noise from missing tables when dropping
        # database.
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore',
                                    module='sqlalchemy.engine.default')
            sqlalchemy_utils.drop_database(self.conf.indexer.url)

        if self.tmp_dir:
            shutil.rmtree(self.tmp_dir)

        if hasattr(self, 'coord'):
            self.coord.stop()

        self.conf.reset()
        if not os.getenv("GNOCCHI_TEST_DEBUG"):
            self.output.cleanUp()
开发者ID:luo-zn,项目名称:gnocchi,代码行数:30,代码来源:fixtures.py

示例3: clean_db

def clean_db(ctx: click.Context):
    """Removes Postgres database."""
    db_uri = make_url(ctx.obj['db_uri'])
    db_uri_str = db_uri.__to_string__()
    if database_exists(db_uri):
        logging.info(f'Cleaning "{db_uri_str}" database.')
        drop_database(db_uri)
开发者ID:lycantropos,项目名称:RecommendSystem,代码行数:7,代码来源:manage.py

示例4: create_ctfd

def create_ctfd(ctf_name="CTFd", name="admin", email="[email protected]", password="password", setup=True):
    app = create_app('CTFd.config.TestingConfig')

    url = make_url(app.config['SQLALCHEMY_DATABASE_URI'])
    if url.drivername == 'postgres':
        url.drivername = 'postgresql'

    if database_exists(url):
        drop_database(url)
        create_database(url)
        with app.app_context():
            app.db.create_all()

    if setup:
        with app.app_context():
            with app.test_client() as client:
                data = {}
                r = client.get('/setup')  # Populate session with nonce
                with client.session_transaction() as sess:
                    data = {
                        "ctf_name": ctf_name,
                        "name": name,
                        "email": email,
                        "password": password,
                        "nonce": sess.get('nonce')
                    }
                client.post('/setup', data=data)
    return app
开发者ID:semprix,项目名称:CTFIgniter,代码行数:28,代码来源:helpers.py

示例5: setup

def setup():
    print(app.config['SQLALCHEMY_DATABASE_URI'])
    engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
    if database_exists(engine.url):
        drop_database(engine.url)
    create_database(engine.url)
    engine.execute('create extension if not exists fuzzystrmatch')
开发者ID:massover,项目名称:jaypeak,代码行数:7,代码来源:manage.py

示例6: dropDatabase

def dropDatabase(dbName):
    """Drop specified database."""
    config = CONFIG_DB
    connectString = "postgresql://{}:{}@{}:{}/{}".format(config["username"],
        config["password"], config["host"], config["port"], dbName)
    if sqlalchemy_utils.database_exists(connectString):
        sqlalchemy_utils.drop_database(connectString)
开发者ID:lisaam,项目名称:data-act-broker-backend,代码行数:7,代码来源:databaseSetup.py

示例7: init_data

def init_data():
    from imports import (
            Widget,Article,Page,
            User,Setting,Type,
            Template,Tag,Role,
            Category,Block,Profile,
            ContactMessage)
    """Fish data for project"""
    if prompt_bool('Do you want to kill your db?'):
        if squ.database_exists(db.engine.url):
            squ.drop_database(db.engine.url)
    try:
        db.drop_all()
    except:
        pass
    try:
        squ.create_database(db.engine.url)
        db.create_all()
    except:
        pass

    user = User.query.filter(User.email=='[email protected]').first()
    if user is None:
       user = User(username='kyle', email='[email protected]', password='14wp88')
    user.save()
开发者ID:4johndoe,项目名称:flask-cms,代码行数:25,代码来源:manage.py

示例8: drop_db

def drop_db(app):
    from project.core.db import db
    from sqlalchemy_utils import database_exists, drop_database
    if database_exists(db.engine.url):
        print '====> Drop database'
        drop_database(db.engine.url)
    else:
        print '====> database not exist'
开发者ID:fuboy,项目名称:tornado-base,代码行数:8,代码来源:manager.py

示例9: book_uri

def book_uri(request):
    name = request.param

    if name and database_exists(name):
        drop_database(name)
    yield name

    if name and database_exists(name):
        drop_database(name)
开发者ID:sdementen,项目名称:piecash,代码行数:9,代码来源:test_helper.py

示例10: createdb

def createdb():
    print "Connecting to %s" % settings.SQLALCHEMY_DATABASE_URI
    engine = create_engine(settings.SQLALCHEMY_DATABASE_URI)
    if settings.DROP_DB_ON_RESTART and database_exists(engine.url):
        print "Dropping old database... (because DROP_DB_ON_RESTART=True)"
        drop_database(engine.url)
    if not database_exists(engine.url):
        print "Creating databases..."
        create_database(engine.url)
开发者ID:occrp,项目名称:osoba,代码行数:9,代码来源:core.py

示例11: setUp

 def setUp(self):
     self.app = self.create_app()
     
     self.db = DB(engine,session,meta)
     import sqlalchemy_utils as squ
     if squ.database_exists(self.db.engine.url):
         squ.drop_database(self.db.engine.url)
     squ.create_database(self.db.engine.url)
     meta.bind = self.db.engine
     meta.create_all()
开发者ID:c0debrain,项目名称:flask-cms,代码行数:10,代码来源:testing.py

示例12: drop

def drop():
    """
    Drop the database if it exists
    :return:
    """
    app.logger.debug('Dropping the database!')
    if database_exists(db.engine.url):
        drop_database(db.engine.url)

    app.logger.error('Database does not exists!')
开发者ID:TheNixNinja,项目名称:flask-boilerplate,代码行数:10,代码来源:orm.py

示例13: app

def app():
    """
    Create test database and application
    """
    app = create_app(testing=True)
    sqlalchemy_url = app.config['SQLALCHEMY_DATABASE_URI']
    if database_exists(sqlalchemy_url):
        drop_database(sqlalchemy_url)
    create_database(sqlalchemy_url)
    yield app
开发者ID:xuhcc,项目名称:airy,代码行数:10,代码来源:conftest.py

示例14: create_sweography_db

def create_sweography_db():

    engine = create_engine(SQLALCHEMY_DATABASE_URI)

    if database_exists(engine.url):
        drop_database(engine.url)
    create_database(engine.url)

    ##creates all tables in database
    Base.metadata.create_all(engine)
开发者ID:asterales,项目名称:cs373-idb,代码行数:10,代码来源:models.py

示例15: new_book_USD

def new_book_USD(request):
    name = request.param

    if name and database_exists(name):
        drop_database(name)

    with create_book(uri_conn=name, currency="USD", keep_foreign_keys=False) as b:
        yield b

    if name and database_exists(name):
        drop_database(name)
开发者ID:sdementen,项目名称:piecash,代码行数:11,代码来源:test_helper.py


注:本文中的sqlalchemy_utils.drop_database函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。