Get a value from sqlite3
961884
def get(key, profile=None):
    '''
    
    '''
    if not profile:
        return None
    _, cur, table = _connect(profile)
    q = profile.get('get_query', ('SELECT value FROM {0} WHERE '
                                  'key=:key'.format(table)))
    res = cur.execute(q, {'key': key})
    res = res.fetchone()
    if not res:
        return None
    return salt.utils.msgpack.unpackb(res[0])
1241361
def from_db_value(self, value, expression, connection, context):
        ''''''
        if value is None:
            return value
        return self.parse_seconds(value)
145585
def sqlite_by_object(self, destination, progress):
        """"""
        db = SQLiteDatabase(destination)
        db.create()
        for script in self.sqlite_dump_string(progress): db.cursor.executescript(script)
        db.close()
1172584
def get_conn(filename):
    """"""
    conn = sqlite3.connect(filename)
    conn.row_factory = _dict_factory
    return conn
134367
def get_sqlite_core(connection_string, *, cursor_factory=None, edit_connection=None):
  """"""
  import sqlite3 as sqlite

  def opener():
    """Opens a single connection with the scope-captured connection string."""
    cn = sqlite.connect(connection_string)
    if cursor_factory:
      cn.row_factory = cursor_factory
    if edit_connection:
      edit_connection(cn)
    return cn

  return InjectedDataAccessCore(
    opener,
    default_connection_closer, (":{0}", "?", SQL_CAST),
    empty_params=[],
    supports_timezones=True,
    supports_returning_syntax=False,
    get_autocommit=get_sqlite_autocommit,
    set_autocommit=set_sqlite_autocommit)
503458
public static function _getValues ($params = array (), &$db = FALSE)
	{
		
		// Set select

		if (!isset ($params['select']))
		{
			$params['select']	= '*';
		}
		
		// Set from

		if (!isset ($params['from']))
		{
			$params['from']		= '`' . static::$dbTable . '`';
		}
		
		// Get database slave for read

		if ($db === FALSE)
		{
			$db	=& self::_getDbSlave ();
		}
		
		// Return value

		return $db->getValues ($params);

	}
822588
def get_number(self, num, table=None):
        """"""
        if table is None: table = self.main_table
        self.own_cursor.execute('SELECT * from "%s" LIMIT 1 OFFSET %i;' % (self.main_table, num))
        return self.own_cursor.fetchone()
607673
def from_db_value(self, value, expression, connection, context):
		
		if value is None:
			return value
		if _using_signed_storage():
			value = _signed_to_unsigned_integer(value)
		return value
1365421
@Override
    public boolean getValue() throws OntopConnectionException {
        if (hasRead)
            throw new IllegalStateException("getValue() can only called once!");
        hasRead = true;
        try {
            return set.next();
        } catch (SQLException e) {
            throw new OntopConnectionException(e);
        }
    }
805899
function sql(str) {
    if (!(this instanceof sql))
      return applyNew(sql, arguments);

    this.str = str;
    this.vals = _.toArray(arguments).slice(1);

    // support passing a single array
    if (_.isArray(this.vals[0]))
      this.vals = this.vals[0];
  }
5017
def _GetValue(self, name):
    """"""
    for value in self.values:
      if value.name == name:
        return value
489557
async def fetchone(self) -> Optional[sqlite3.Row]:
        """"""
        return await self._execute(self._cursor.fetchone)
478283
def process_result_value(self, value: Optional[str],
                             dialect: Dialect) -> List[str]:
        """"""
        retval = self._dbstr_to_strlist(value)
        return retval
974312
def get_jid(jid):
    '''
    
    '''
    log.debug('sqlite3 returner <get_jid> called jid: %s', jid)
    conn = _get_conn(ret=None)
    cur = conn.cursor()
    sql = '''SELECT id, full_ret FROM salt_returns WHERE jid = :jid'''
    cur.execute(sql,
                {'jid': jid})
    data = cur.fetchone()
    log.debug('query result: %s', data)
    ret = {}
    if data and len(data) > 1:
        ret = {six.text_type(data[0]): {'return': salt.utils.json.loads(data[1])}}
        log.debug('ret: %s', ret)
    _close_conn(conn)
    return ret
641582
def get_fun(fun):
    '''
    
    '''
    log.debug('sqlite3 returner <get_fun> called fun: %s', fun)
    conn = _get_conn(ret=None)
    cur = conn.cursor()
    sql = '''SELECT s.id, s.full_ret, s.jid
            FROM salt_returns s
            JOIN ( SELECT MAX(jid) AS jid FROM salt_returns GROUP BY fun, id) max
            ON s.jid = max.jid
            WHERE s.fun = :fun
            '''
    cur.execute(sql,
                {'fun': fun})
    data = cur.fetchall()
    ret = {}
    if data:
        # Pop the jid off the list since it is not
        # needed and I am trying to get a perfect
        # pylint score :-)
        data.pop()
        for minion, ret in data:
            ret[minion] = salt.utils.json.loads(ret)
    _close_conn(conn)
    return ret
927283
def _get_conn(ret=None):
    '''
    
    '''
    # Possible todo: support detect_types, isolation_level, check_same_thread,
    # factory, cached_statements. Do we really need to though?
    _options = _get_options(ret)
    database = _options.get('database')
    timeout = _options.get('timeout')

    if not database:
        raise Exception(
                'sqlite3 config option "sqlite3.database" is missing')
    if not timeout:
        raise Exception(
                'sqlite3 config option "sqlite3.timeout" is missing')
    log.debug('Connecting the sqlite3 database: %s timeout: %s', database, timeout)
    conn = sqlite3.connect(database, timeout=float(timeout))
    return conn
767447
def select(self, db):
        """"""
        if not isinstance(db, int):
            raise TypeError("DB must be of int type, not {!r}".format(db))
        if db < 0:
            raise ValueError("DB must be greater or equal 0, got {!r}"
                             .format(db))
        fut = self.execute('SELECT', db)
        return wait_ok(fut)