Create a sqlite3 db at the given path.
    Create all the tables and indexes we need.
188683
def namedb_create(path, genesis_block):
    

    global BLOCKSTACK_DB_SCRIPT

    if os.path.exists( path ):
        raise Exception("Database '%s' already exists" % path)

    lines = [l + ";" for l in BLOCKSTACK_DB_SCRIPT.split(";")]
    con = sqlite3.connect( path, isolation_level=None, timeout=2**30 )

    for line in lines:
        db_query_execute(con, line, ())

    con.row_factory = namedb_row_factory

    # create genesis block
    namedb_create_token_genesis(con, genesis_block['rows'], genesis_block['history'])
    return con
657127
def _open_sqlite(db_file):
    """"""
    db_file = os.path.expanduser(db_file)
    try:
        with open(db_file):
            # test that the file can be accessed
            pass
        return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
    except (IOError, sqlite3.Error) as err:
        raise Dump2PolarionException("{}".format(err))
651130
def init_db():
    
    with current_app.app_context():
        for filename in CHILL_CREATE_TABLE_FILES:
            db.execute(text(fetch_query_string(filename)))
164023
def instantiate_database(sqlite_file='ftwj.sqlite'):
    
    table_name = 'ftw'
    col1 = 'rule_id'
    col1_t = 'INTEGER'
    col2 = 'test_id'
    col2_t = 'STRING'
    col3 = 'time_start'
    col3_t = 'TEXT'
    col4 = 'time_end'
    col4_t = 'TEXT'
    col5 = 'response_blob'
    col5_t = 'TEXT'
    col6 = 'status_code'
    col6_t = 'INTEGER'
    col7 = 'stage'
    col7_t = 'INTEGER'
    conn = sqlite3.connect(sqlite_file)
    cur = conn.cursor()

    q = 'CREATE TABLE {tn}({col1} {col1_t},{col2} {col2_t},{col3} {col3_t},{col4} {col4_t},{col5} {col5_t},{col6} {col6_t},{col7} {col7_t})'.format(
        tn=table_name,
        col1=col1, col1_t=col1_t,
        col2=col2, col2_t=col2_t,
        col3=col3, col3_t=col3_t,
        col4=col4, col4_t=col4_t,
        col5=col5, col5_t=col5_t,
        col6=col6, col6_t=col6_t,
        col7=col7, col7_t=col7_t)
    cur.execute(q)
    conn.commit()
    conn.close()
14127
def create(self, path, data=None):
        
        node = self.current[-1]
        path = self._splitpath(path)
        n_items = len(path)
        for n, item in enumerate(path):
            tag, attribs = self._splittag(item)

            # The leaf node is always newly created.
            if n == n_items-1:
                node = node.add(Node(tag, attribs))
                break

            # Parent nodes are only created if they do not exist yet.
            existing = node.get_child(tag, attribs)
            if existing is not None:
                node = existing
            else:
                node = node.add(Node(tag, attribs))
        if data:
            node.text = unquote(data)
        return node
132595
public static SQLiteDatabase openOrCreateDatabase(String path, CursorFactory factory,
            DatabaseErrorHandler errorHandler) {
        return openDatabase(path, factory, CREATE_IF_NECESSARY, errorHandler);
    }
417324
def create_directory(self, path):
        
        _complain_ifclosed(self.closed)
        return self.fs.create_directory(path)
1171073
def make_cursor(path, init_statements=(), _connectioncache={}):
    """"""
    connection = _connectioncache.get(path)
    if not connection:
        is_new = not os.path.exists(path) or not os.path.getsize(path)
        try: is_new and os.makedirs(os.path.dirname(path))
        except OSError: pass
        connection = sqlite3.connect(path, isolation_level=None,
            check_same_thread=False, detect_types=sqlite3.PARSE_DECLTYPES)
        for x in init_statements or (): connection.execute(x)
        try: is_new and ":memory:" not in path.lower() and os.chmod(path, 0707)
        except OSError: pass
        connection.row_factory = lambda cur, row: dict(sqlite3.Row(cur, row))
        _connectioncache[path] = connection
    return connection.cursor()
216083
def init_db(uri, base, **kwargs):
    
    engine = create_engine(uri, **kwargs)
    base.metadata.create_all(engine)
    return engine
67130
private void bootFromDsqls(String path) {
        File[] files = new File(path).listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".sql");
            }
        });
        
        for (File file:files) {//In this context only add/update is cared for.
            sqlSniffer.onCreate(Paths.get(file.toURI()));
        }        
    }
1327451
def create_db(self, app):
        """"""
        assert 'ZODB_STORAGE' in app.config, \
               'ZODB_STORAGE not configured'
        storage = app.config['ZODB_STORAGE']
        if isinstance(storage, basestring):
            factory, dbargs = zodburi.resolve_uri(storage)
        elif isinstance(storage, tuple):
            factory, dbargs = storage
        else:
            factory, dbargs = storage, {}
        return DB(factory(), **dbargs)
403497
def create_db():
    
    from flask_appbuilder.models.sqla import Model

    engine = current_app.appbuilder.get_session.get_bind(mapper=None, clause=None)
    Model.metadata.create_all(engine)
    click.echo(click.style("DB objects created", fg="green"))
763883
def _create_tables(self):
        
        cursor = self.conn.cursor()

        create_cmd = """CREATE TABLE IF NOT EXISTS {} (
        fully_qualified_subdomain TEXT NOT NULL,
        domain TEXT NOT NULL,
        sequence INTEGER NOT NULL,
        owner TEXT NOT NULL,
        zonefile_hash TEXT NOT NULL,
        signature TEXT NOT NULL,
        block_height INTEGER NOT NULL,
        parent_zonefile_hash TEXT NOT NULL,
        parent_zonefile_index INTEGER NOT NULL,
        zonefile_offset INTEGER NOT NULL,
        txid TEXT NOT NULL,
        missing TEXT NOT NULL,
        accepted INTEGER NOT NULL,
        resolver TEXT,
        PRIMARY KEY(fully_qualified_subdomain,parent_zonefile_index));
        """.format(self.subdomain_table)
        db_query_execute(cursor, create_cmd, ())

        # set up a queue as well
        queue_con = queuedb_open(self.queue_path)
        queue_con.close()
623147
def create(self):
        """"""

        if not self.exists():
            self._create_path()
            self.create_tables()
            return True

        return False
161892
def create_db(name, **client_args):
    '''
    
    '''
    if db_exists(name, **client_args):
        log.info('DB \'%s\' already exists', name)
        return False

    client = _client(**client_args)
    client.create_database(name)

    return True
884536
def save(self, directory=None):
        
        from subprocess import call

        # If user did not supply a new directory, use the one loaded (default: tabledata)
        if isinstance(directory, type(None)):
            directory = self.directory

        # Create the .sql file is it doesn't exist, i.e. if the Database class called a .db file initially
        if not os.path.isfile(self.sqlpath):
            self.sqlpath = self.dbpath.replace('.db', '.sql')
            os.system('touch {}'.format(self.sqlpath))

        # # Write the data to the .sql file
        # with open(self.sqlpath, 'w') as f:
        #     for line in self.conn.iterdump():
        #         f.write('%s\n' % line)

        # Alternatively...
        # Write the schema
        os.system("echo '.output {}\n.schema' | sqlite3 {}".format(self.sqlpath, self.dbpath))

        # Write the table files to the tabledata directory
        os.system("mkdir -p {}".format(directory))
        tables = self.query("select tbl_name from sqlite_master where type='table'")['tbl_name']
        tablepaths = [self.sqlpath]
        for table in tables:
            print('Generating {}...'.format(table))
            tablepath = '{0}/{1}.sql'.format(directory, table)
            tablepaths.append(tablepath)
            with open(tablepath, 'w') as f:
                for line in self.conn.iterdump():
                    line = line.strip()
                    if line.startswith('INSERT INTO "{}"'.format(table)):
                        if sys.version_info.major == 2:
                            f.write(u'{}\n'.format(line).encode('utf-8'))
                        else:
                            f.write(u'{}\n'.format(line))

        print("Tables saved to directory {}/".format(directory))
        print("""=======================================================================================
You can now run git to commit and push these changes, if needed.
For example, if on the master branch you can do the following:
  git add {0} {1}/*.sql
  git commit -m "COMMIT MESSAGE HERE"
  git push origin master
You can then issue a pull request on GitHub to have these changes reviewed and accepted
======================================================================================="""
              .format(self.sqlpath, directory))
244967
def create_db():
    "  "

    from ..ext import db
    db.create_all()

    # Evolution support
    from flask import current_app
    from flaskext.evolution import db as evolution_db
    evolution_db.init_app(current_app)
    evolution_db.create_all()

    print "Database created successfuly"