Create a new connection to the SQLite3 database.

        :param dbname: The database name
        :type dbname: str
18885
def connect(cls, dbname):
        
        test_times_schema = """
        CREATE TABLE IF NOT EXISTS test_times (
          file text,
          module text,
          class text,
          func text,
          elapsed float
        )
        """
        
        setup_times_schema = """
        CREATE TABLE IF NOT EXISTS setup_times (
          file text,
          module text,
          class text,
          func text,
          elapsed float
        )
        """
        
        schemas = [test_times_schema,
                   setup_times_schema]
        
        db_file = '{}.db'.format(dbname)
                
        cls.connection = sqlite3.connect(db_file)
        for s in schemas:
            cls.connection.execute(s)
289235
def _create_db(self):
        
        log.debug("Creating sqlite database")
        self._conn = sqlite3.connect(self._db_filename)

        # create table structure
        self._conn.cursor().execute("""
        CREATE TABLE IF NOT EXISTS {}
        (
          ts REAL,
          arbitration_id INTEGER,
          extended INTEGER,
          remote INTEGER,
          error INTEGER,
          dlc INTEGER,
          data BLOB
        )
        """.format(self.table_name))
        self._conn.commit()

        self._insert_template = "INSERT INTO {} VALUES (?, ?, ?, ?, ?, ?, ?)".format(self.table_name)
1048503
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
	{
		if (empty($argHostname) && $argDatabasename) {
			$argHostname = $argDatabasename;
		}
		$this->_connectionID = new SQLite3($argHostname);
		$this->_createFunctions();

		return true;
	}
613090
def _setup_db(cls):
        
        uri = cls._app.config.get("DB_URL")
        if uri:
            db.connect__(uri, cls._app)
1339741
def _conn(queue):
    '''
    
    '''
    queue_dir = __opts__['sqlite_queue_dir']
    db = os.path.join(queue_dir, '{0}.db'.format(queue))
    log.debug('Connecting to: %s', db)

    con = sqlite3.connect(db)
    tables = _list_tables(con)
    if queue not in tables:
        _create_table(con, queue)
    return con
1035753
def create_database(self):
        
        if not self._database_exists():
            con = psycopg2.connect(host=self.host, database="postgres",
                user=self.user, password=self.password, port=self.port)
            con.set_isolation_level(
                psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
            query = "CREATE DATABASE {0};".format(self.dbname)
            c = con.cursor()
            c.execute(query)            
            con.close()


            if self.normalize:
                self.open_database()
                query = "CREATE EXTENSION IF NOT EXISTS \"plperlu\";"
                self.execute_sql(query)
    #            query = """CREATE OR REPLACE FUNCTION normalize(str text)
    #RETURNS text
    #AS $$
    #import unicodedata
    #return ''.join(c for c in unicodedata.normalize('NFKD', str)
    #if unicodedata.category(c) != 'Mn')
    #$$ LANGUAGE plpython3u IMMUTABLE;"""
    #             query = """CREATE OR REPLACE FUNCTION normalize(mystr text)
    #   RETURNS text
    # AS $$
    #     from unidecode import unidecode
    #     return unidecode(mystr.decode("utf-8"))
    # $$ LANGUAGE plpythonu IMMUTABLE;"""
                query = """CREATE OR REPLACE FUNCTION normalize(text)
      RETURNS text
    AS $$
        use Text::Unidecode;
        return unidecode(shift);
    $$ LANGUAGE plperlu IMMUTABLE;"""
                self.execute_sql(query)
                self.commit()
                self.close_database()
1116353
def db(cls, dbname=None):
        

        cls._load_entry_points()

        dbname = dbname or config.get('eop', 'dbname', fallback=cls.DEFAULT_DBNAME)

        if dbname not in cls._dbs.keys():
            raise EopError("Unknown database '%s'" % dbname)

        if isclass(cls._dbs[dbname]):
            # Instanciation
            try:
                cls._dbs[dbname] = cls._dbs[dbname]()
            except Exception as e:
                # Keep the exception in cache in order to not retry instanciation
                # every single time EopDb.db() is called, as instanciation
                # of database is generally a time consumming operation.
                # If it failed once, it will most probably fail again
                cls._dbs[dbname] = e

        if isinstance(cls._dbs[dbname], Exception):
            raise EopError("Problem at database instanciation") from cls._dbs[dbname]

        return cls._dbs[dbname]
821342
def _database_create(self, engine, database):
        
        logger.info('Creating database "%s" in "%s"', database, engine)
        database_operation(engine, 'create', database)
        url = copy(engine.url)
        url.database = database
        return str(url)
952873
def create(self, db_name, **kwargs):
        
        db = PostgresDatabase(
            db_name, host=self.host, port=self.port,
            superuser=self.superuser, **kwargs)
        db.ensure_user()
        db.create()
        return db
834068
def connect(self, *, db=None):
        
        if db:
            self.poll(command="stop")
            self.properties.db_name = db.split(".")[0]
            self.new_state(DeviceFromDB)
        else:
            self._log.warning(
                "Already connected, provide db arg if you want to connect to db"
            )
97459
def connectDb(engine   = dbeng,
              user     = dbuser,
              password = dbpwd,
              host     = dbhost,
              port     = dbport,
              database = dbname,
              params   = "?charset=utf8&use_unicode=1",
              echoopt  = False):
    
    return create_engine('%s://%s:%s@%s:%s/%s%s' % (engine, user, password, host, port, database, params), echo=echoopt)
121485
def connect(self, db_uri, debug=False):
        
        kwargs = {'echo': debug, 'convert_unicode': True}
        # connect to the SQL database
        if 'mysql' in db_uri:
            kwargs['pool_recycle'] = 3600
        elif '://' not in db_uri:
            logger.debug("detected sqlite path URI: {}".format(db_uri))
            db_path = os.path.abspath(os.path.expanduser(db_uri))
            db_uri = "sqlite:///{}".format(db_path)

        self.engine = create_engine(db_uri, **kwargs)
        logger.debug('connection established successfully')
        # make sure the same engine is propagated to the BASE classes
        BASE.metadata.bind = self.engine
        # start a session
        self.session = scoped_session(sessionmaker(bind=self.engine))
        # shortcut to query method
        self.query = self.session.query
        return self
1096198
def load(dbname):
    
    db = Database(dbname)

    # Get the name of the objects
    tables = get_table_list(db.cur)

    # Create a Trace instance for each object
    chains = 0
    for name in tables:
        db._traces[name] = Trace(name=name, db=db)
        db._traces[name]._shape = get_shape(db.cur, name)
        setattr(db, name, db._traces[name])
        db.cur.execute('SELECT MAX(trace) FROM [%s]' % name)
        chains = max(chains, db.cur.fetchall()[0][0] + 1)

    db.chains = chains
    db.trace_names = chains * [tables, ]
    db._state_ = {}
    return db
1262129
def create(self):
    
    data = data={"db-name":self.db}
    self.rest('POST', self.uri_str, status_codes=(200,201), data=data)
    return True
542574
private static void createDB(String dbName) {
        // remove database if it exists
        if (ZooHelper.dbExists(dbName)) {
            ZooHelper.removeDb(dbName);
        }

        // create database
        // By default, all database files will be created in %USER_HOME%/zoodb
        ZooHelper.createDb(dbName);
    }
702157
def db_create(database, containment='NONE', new_database_options=None, **kwargs):
    '''
    
    '''
    if containment not in ['NONE', 'PARTIAL']:
        return 'CONTAINMENT can be one of NONE and PARTIAL'
    sql = "CREATE DATABASE [{0}] CONTAINMENT = {1} ".format(database, containment)
    if new_database_options:
        sql += ' WITH ' + ', '.join(new_database_options)
    conn = None
    try:
        conn = _get_connection(**kwargs)
        conn.autocommit(True)
        # cur = conn.cursor()
        # cur.execute(sql)
        conn.cursor().execute(sql)
    except Exception as e:
        return 'Could not create the login: {0}'.format(e)
    finally:
        if conn:
            conn.autocommit(False)
            conn.close()
    return True
129082
def _connect(self):
        
        if self._connection is not None:
            raise RuntimeError('Close connection first.')
        self._connection = connect(self._database, **self._kwds)
        self._connection.isolation_level = None