Given a DBID, get the QuickBase realm it is in.
424275
def getRealmForDbid(dbid)
      @realm = nil
      if USING_HTTPCLIENT
         begin
            httpclient = HTTPClient.new
            resp = httpclient.get("https://www.quickbase.com/db/#{dbid}")
            location = resp.header['Location'][0]
            location.sub!("https://","")
            parts = location.split(/\./)
            @realm = parts[0]
         rescue StandardError => error
            @realm = nil 
         end
      else
         raise "Please get the HTTPClient gem: gem install httpclient" 
      end   
      @realm
   end
905221
def lookupChdbid( tableName, dbid=nil )
      getSchema(dbid) if dbid
      unmodifiedTableName = tableName.dup
      @chdbid = findElementByAttributeValue( @chdbids, "name", formatChdbidName( tableName ) )
      if @chdbid
         @dbid = @chdbid.text
         return @dbid
      end
      if @chdbids
         chdbidArray = findElementsByAttributeName( @chdbids, "name" )
         chdbidArray.each{ |chdbid|
            if chdbid.has_text?
               dbid = chdbid.text
               getSchema( dbid )
               name = getResponseElement( "table/name" )
               if name and name.has_text? and name.text.downcase == unmodifiedTableName.downcase
                  @chdbid = chdbid
                  @dbid = dbid
                  return @dbid
               end
            end
         }
      end
      nil
   end
415945
def database(key='default', slave=False):
    
    if slave:
        key += '.slave'
        return choice(__db[key])
    return __db.get(key)
979568
def get(self, key=None, view=None):
        """"""
        self.set_header("Access-Control-Allow-Origin", "*")
        self.set_header("Content-Type", "application/json")
        if key is not None:
            value = {}
            value.update(self.database[key])
            if view is not None:
                # generate a context with the relevant variables
                context = {}
                context["value"] = value
                context["ctx"] = self.ctx
                result = json.dumps(getattr(views, view)(context))
            else:
                result = json.dumps(value)
        else:
            result = json.dumps(self.database.values())

        self.write(result)
195573
function getDatabase(index, opts) {
  var db;
  if(!this._databases[index]) {
    db = new Database(this, opts);
    this._databases[index] = db;
  }
  return this._databases[index];
}
666779
def get(no_create=False, server=None, port=None, force_uuid=None):
        """"""
        pid = os.getpid()
        thread = threading.current_thread()
        wdb = Wdb._instances.get((pid, thread))
        if not wdb and not no_create:
            wdb = object.__new__(Wdb)
            Wdb.__init__(wdb, server, port, force_uuid)
            wdb.pid = pid
            wdb.thread = thread
            Wdb._instances[(pid, thread)] = wdb
        elif wdb:
            if (server is not None and wdb.server != server
                    or port is not None and wdb.port != port):
                log.warn('Different server/port set, ignoring')
            else:
                wdb.reconnect_if_needed()
        return wdb
76104
protected Table getTableFromDB(String tableName) {
        Table table = m_db.getTables().getExact(tableName);
        return table;
    }
1264149
def _get_session():
    """"""
    session = getattr(g, '_session', None)
    if session is None:
        session = g._session = db.session()
    return session
52456
public TResult queryForId(long id) {
		String where = getPkWhere(id);
		String[] whereArgs = getPkWhereArgs(id);
		TResult result = userDb.query(getTableName(), table.getColumnNames(),
				where, whereArgs, null, null, null);
		prepareResult(result);
		return result;
	}
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)
977305
@Override
  public Realm getRealm(String realmName, ApplicationId applicationId) {
    RealmSet rs = this.realmNameToRealmSet.get(realmName);
    return rs == null ? null : rs.getRealm(applicationId);
  }
281903
function getUserOrganizationId (id, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const sqlQuery = SQL`
        SELECT org_id
        FROM users
        WHERE id = ${id}
      `
      db.query(sqlQuery, function (err, result) {
        if (err) return cb(Boom.badImplementation(err))
        if (result.rowCount === 0) return cb(Boom.notFound())

        return cb(null, result.rows[0].org_id)
      })

      return promise
    }
1008133
@FFDCIgnore(InvocationTargetException.class)
    Object getDB(String databaseName) throws Exception {
        final boolean trace = TraceComponent.isAnyTracingEnabled();

        lock.readLock().lock();
        try {
            if (mongoClient == null) {
                // Switch to write lock for lazy initialization
                lock.readLock().unlock();
                lock.writeLock().lock();
                try {
                    if (mongoClient == null)
                        init();
                } finally {
                    // Downgrade to read lock for rest of method
                    lock.readLock().lock();
                    lock.writeLock().unlock();
                }
            }

            Object db = MongoClient_getDB.invoke(mongoClient, databaseName);

            // authentication
            String user = (String) props.get(USER);
            if (user != null) {
                if ((Boolean) DB_isAuthenticated.invoke(db)) {
                    if (trace && tc.isDebugEnabled())
                        Tr.debug(this, tc, "already authenticated");
                } else {
                    if (trace && tc.isDebugEnabled())
                        Tr.debug(this, tc, "authenticate as: " + user);
                    SerializableProtectedString password = (SerializableProtectedString) props.get(PASSWORD);
                    String pwdStr = password == null ? null : String.valueOf(password.getChars());
                    pwdStr = PasswordUtil.getCryptoAlgorithm(pwdStr) == null ? pwdStr : PasswordUtil.decode(pwdStr);
                    char[] pwdChars = pwdStr == null ? null : pwdStr.toCharArray();
                    try {
                        if (!(Boolean) DB_authenticate.invoke(db, user, pwdChars))
                            if ((Boolean) DB_isAuthenticated.invoke(db)) {
                                if (trace && tc.isDebugEnabled())
                                    Tr.debug(this, tc, "another thread must have authenticated first");
                            } else
                                throw new IllegalArgumentException(Tr.formatMessage(tc, "CWKKD0012.authentication.error", MONGO, id, databaseName));
                    } catch (InvocationTargetException x) {
                        // If already authenticated, Mongo raises:
                        // IllegalStateException: can't authenticate twice on the same database
                        // Maybe another thread did the authentication right after we checked, so check again.
                        Throwable cause = x.getCause();
                        if (cause instanceof IllegalStateException && (Boolean) DB_isAuthenticated.invoke(db)) {
                            if (trace && tc.isDebugEnabled())
                                Tr.debug(this, tc, "another thread must have authenticated first", cause);
                        } else
                            throw cause;
                    }
                }
            } else if (useCertAuth) {
                // If we specified a certificate we will already have used the client constructor that
                // specified the credential so if we have got to here we are already authenticated and
                // JIT should remove this so it will not be an overhead.
            }
            return db;
        } catch (Throwable x) {
            // rethrowing the exception allows it to be captured in FFDC and traced automatically
            x = x instanceof InvocationTargetException ? x.getCause() : x;
            if (x instanceof Exception)
                throw (Exception) x;
            else if (x instanceof Error)
                throw (Error) x;
            else
                throw new RuntimeException(x);
        } finally {
            lock.readLock().unlock();
        }
    }
163172
def get(cls, id_):
        """"""
        with db.session.no_autoflush:
            query = cls.dbmodel.query.filter_by(id=id_)
            try:
                model = query.one()
            except NoResultFound:
                raise WorkflowsMissingObject("No object for for id {0}".format(
                    id_
                ))
            return cls(model)
773669
public function getDigestHash($realm, $username)
    {
        $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?');
        $stmt->execute([$username]);

        return $stmt->fetchColumn() ?: null;
    }
353759
def db(ctx):
    """"""

    from hfos import database
    database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
    ctx.obj['db'] = database
781016
def get_filter_qobj(self, keys=None):
    
    # only care about columns in aggregates right?
    cols = set()
    for agg in self.select.aggregates:
        cols.update(agg.cols)
    sels = [SelectExpr(col, [col], col, None) for col in cols]
    select = Select(sels)
    where = list(self.where)
    if keys:
      keys = list(keys)
      keys = map(sqlize, list(keys))
      expr = self.select.nonaggs[0].expr

      clause = []
      if None in keys:
        clause.append("%s is null" % expr)
      if len([k for k in keys if k is not None]) > 0:
        clause.append("%s in %%s" % expr)
      clause = " or ".join(clause)
      where.append(clause)
    else:
      where.append( '%s = %%s' % (self.select.nonaggs[0].expr ) )
    q = Query(self.db, select, self.fr, where)
    return q