Returns the singleton connection to the SQLite3 database.

        :param dbname: The database name
        :type dbname: str
428169
def get(cls, dbname="perfdump"):
        
        try:
            return cls.connection
        except:
            cls.connect(dbname)
            return cls.connection
635932
def db(self, connection_string=None):
        """"""

        connection_string = connection_string or self.settings["db"]

        if not hasattr(self, "_db_conns"):
            self._db_conns = {}
        if not connection_string in self._db_conns:
            self._db_conns[connection_string] = oz.sqlalchemy.session(connection_string=connection_string)

        return self._db_conns[connection_string]
169028
def listTables(self, dbName=None):
        
        if dbName is None:
            dbName = self.currentDatabase()
        iter = self._jcatalog.listTables(dbName).toLocalIterator()
        tables = []
        while iter.hasNext():
            jtable = iter.next()
            tables.append(Table(
                name=jtable.name(),
                database=jtable.database(),
                description=jtable.description(),
                tableType=jtable.tableType(),
                isTemporary=jtable.isTemporary()))
        return tables
778177
def get_session(db_path: str):
    
    # cfg = Config()
    # db_path = cfg.get(ConfigKeys.asset_allocation_database_path)

    # connection
    con_str = "sqlite:///" + db_path
    # Display all SQLite info with echo.
    engine = create_engine(con_str, echo=False)

    # create metadata (?)
    Base.metadata.create_all(engine)

    # create session
    Session = sessionmaker(bind=engine)
    session = Session()

    return session
1055467
def _get_db_connect(dbSystem,db,user,password):
    
    if dbSystem=='SYBASE':
        import Sybase    
        try:
            dbh = Sybase.connect(dbSystem,
                                 user,
                                 password,
                                 database=db )
        except:
            dbh=None
    elif dbSystem=='MYSQL':
        import MySQLdb
        try:
            dbh = MySQLdb.connect(user=user,
                                  passwd=password,
                                  db=db ,
                                  host='gimli')
        except:
            dbh=None
            
    return dbh
737297
def get_db(directory, engine=None):
    
    if engine is None:
        engine = create_engine('sqlite://')
    tables.metadata.create_all(engine)
    Session = sessionmaker(bind=engine)
    db = Session()
    if directory is not None:
        load_from_directory(db, directory)
    return db
499440
def _get_db(self):
        
        if self._connection:
            try:
                self._connection.close()
            except Exception:
                pass

        return DB(storageFromFile(open(self.conf_path)))
164686
def connect(self, *args, **kwargs):
        
        self.db = sqlite3.connect(*args, **kwargs)
        self.db.isolation_level = None
292999
def _get_session(self):
        
        if self._session is None:
            session = self._session = self._database.session()
            session.create()
        return self._session
581777
def database_caller_creator(self, name=None):
        '''
        '''

        try:
            if name:
                database = name + '.db'
            else:
                database = 'sqlite_' + str_generator(self) + '.db'

            conn = sqlite3.connect(database)
            logger.warning('Database created and opened succesfully: %s' % database, extra=d)
        except Exception:
            logger.error('Failed to connect or create database / sqlite3', extra=d)
            raise DbConnException

        return conn
655399
def _get_column_by_db_name(cls, name):
        
        return cls._columns.get(cls._db_map.get(name, name))
342018
def get_table(self, dbname, tbl_name):
    
    self.send_get_table(dbname, tbl_name)
    return self.recv_get_table()
151294
def ReadDatabase(self, database_link, options=None):
        
        if options is None:
            options = {}

        path = base.GetPathFromLink(database_link)
        database_id = base.GetResourceIdOrFullNameFromLink(database_link)
        return self.Read(path, 'dbs', database_id, None, options)
132450
def connect_db(Repo, database=":memory:"):
        
        Repo.db = sqlite3.connect(database,
                                  detect_types=sqlite3.PARSE_DECLTYPES)
        return Repo.db
957888
static synchronized SQLiteDatabase getDatabase() {
        if(sInstance == null) {
           throw new SprinklesNotInitializedException();
        }

        if(sDatabase == null) {
            DbOpenHelper dbOpenHelper = new DbOpenHelper(sInstance.mContext, sInstance.databaseName, sInstance.initialDatabaseVersion);
            sDatabase = dbOpenHelper.getWritableDatabase();
        }

        return sDatabase;
    }
895109
def _conn_string_odbc(self, db_key, instance=None, conn_key=None, db_name=None):
        ''' 
        '''
        if instance:
            dsn, host, username, password, database, driver = self._get_access_info(instance, db_key, db_name)
        elif conn_key:
            dsn, host, username, password, database, driver = conn_key.split(":")

        conn_str = ''
        if dsn:
            conn_str = 'DSN={};'.format(dsn)

        if driver:
            conn_str += 'DRIVER={};'.format(driver)
        if host:
            conn_str += 'Server={};'.format(host)
        if database:
            conn_str += 'Database={};'.format(database)

        if username:
            conn_str += 'UID={};'.format(username)
        self.log.debug("Connection string (before password) {}".format(conn_str))
        if password:
            conn_str += 'PWD={};'.format(password)
        return conn_str
1326355
def create(database, tlmdict=None):
    
    if tlmdict is None:
        tlmdict = tlm.getDefaultDict()
    
    dbconn = connect(database)

    for name, defn in tlmdict.items():
        createTable(dbconn, defn)

    return dbconn