Moved to DbHelper
@deprecated
192641
@Deprecated 
	private String idSuffix(String name, DomainObject to) {
		if (useIdSuffixInForeignKey()) {
			Attribute idAttribute = getIdAttribute(to);
			if (idAttribute != null) {
				String idName = idAttribute.getDatabaseColumn().toUpperCase();
				String convertedName = convertDatabaseName(name);
				if (idName.equals(convertedName) && idName.startsWith(to.getDatabaseTable())) {
					idName = idName.substring(to.getDatabaseTable().length());
				} else if (idName.startsWith(convertedName)) {
					idName = idName.substring(convertedName.length());
				}
				if (idName.startsWith("_")) {
					return idName;
				} else {
					return ("_" + idName);
				}
			}
		}
		return "";
	}
61122
def DatabaseEnabled(cls):
    
    if not issubclass(cls, Storable):
        raise ValueError(
            "%s is not a subclass of gludb.datab.Storage" % repr(cls)
        )

    cls.ensure_table = classmethod(_ensure_table)
    cls.find_one = classmethod(_find_one)
    cls.find_all = classmethod(_find_all)
    cls.find_by_index = classmethod(_find_by_index)
    cls.save = _save
    cls.delete = _delete

    return cls
28405
function (dbName, sql) {
  EventEmitter.apply(this, arguments); // apply parent constructor

  this._addSqlErrorListener(); // register error handler before any SQL is executed

  this._dbName = dbName;
  this._sql = sql ? sql : new SQL(); // TODO: remove new SQL() as sql should always be injected
  this._registerDisconnectListener();

  this._globals = new Globals(this._sql);
  this._roles = new Roles(this._sql, this);
  this._userRoles = new UserRoles(this._sql);
  this._users = new Users(this._sql, this._roles, this._userRoles, this);
  this._colRoles = new ColRoles(this._sql);
  this._policy = new Policy(this._sql, this._roles, this._colRoles, this._userRoles);
  this._cols = new Cols(this._sql, this._policy);
  // this._sessions = new Sessions(this._sql, this._users);

  this._initPartitions();

  this._archive = new Archive(this._partitions, this._globals);
  this._attrs = new Attrs(this._partitions, this._policy, this._users, this._roles, this);
  this._docs = new Docs(this._partitions, this._attrs, this._policy, this._cols);
  this._attrs._docs = this._docs;
  this._queueAttrRecs = new QueueAttrRecs(this._sql);
  this._queue = new Queue(this._sql);
  this._process = new Process(this._sql, this._docs, this._users, this._queueAttrRecs,
    this._partitions, this._cols, this._policy, this._roles,
    this._userRoles, this._attrs, this);
  this._changes = new Changes(this._sql, this._globals, this._users);

  this._models = [this._globals, this._cols, this._users, this._roles, this._userRoles,
    this._colRoles, this._queueAttrRecs
    // this._sessions
  ];
}
1060266
public static DBID deref(DBIDRef ref) {
    return ref instanceof DBID ? (DBID) ref : importInteger(ref.internalGetIndex());
  }
540993
@Deprecated
    public String registerTableOverride(String oldTable, String newTable) {
        return internalNameMapping.registerTableOverride(oldTable, newTable);
    }
916722
function (db, options, cb) {
	this.db = db;
	this.cb = cb;
	this.updateQueryMaker = options.update;
	this.insertQueryMaker = options.insert;
	this.maxUpdateAttemptsCount = options.maxUpdateAttemptsCount || 2;
	this.transform = options.transform;
	this.insertFirst = !!options.insertFirst;
	this.nonQuery = !!options.nonQuery;

	var self = this;
	this.updateAttemptsCount = 0;
	this.updateOrInsertBound = function () {
		self.updateOrInsert();
	};
}
419595
@Deprecated
	public static SqlRunner newSqlRunner(DataSource ds, Dialect dialect) {
		return SqlRunner.create(ds, dialect);
	}
1040748
function DbWriter(db,errorLogObject,successLogObject) {
	this.db = db;
	this.errorLogObject = errorLogObject;
	this.successLogObject = successLogObject;
}
1313784
def method_missing(name, *args)
      groupname = (args[0] or raise "Database configuration group not specified for #{name}")
      dbname = (args[1] or raise "Database entry name not specified for #{name}")
      n = name.to_s
      begin
        unseparated_yaml(n => self[groupname, dbname])
      rescue Bcdatabase::Error => e
        if ENV['RAILS_ENV'] == n
          raise e
        else
          # Not using that configuration right now, so return a dummy instead
          # of throwing an exception
          unseparated_yaml(n => { 'error' => e.message })
        end
      end
    end
826005
private function actionDatabaseImport(SymfonyStyle $helper)
    {
        $connectionParameters = $this->getDoctrineManager()->getConnection()->getParams();

        $timestamp = date('ymdHi');
        $databaseName = $connectionParameters['dbname'];

        /*
         * Select Host
         */
        $remoteHost = $helper->ask('Remote host');

        /*
         * Select Username
         */
        $remoteUser = $helper->ask('Remote user name', 'root');

        /*
         * Select external database (default: database_name)
         */
        $remoteDatabase = $helper->ask('Remote database', $databaseName);

        /*
         * Local database informations
         */
        $localDatabaseHost = $helper->ask('Local database host', $connectionParameters['host']);
        $localDatabaseName = $helper->ask('New local database name', sprintf('%s_%s', $connectionParameters['dbname'], $timestamp));
        $localDatabaseUser = $helper->ask('Local database user', $connectionParameters['user']);

        /*
         * mysqldump
         */
        $fileName = sprintf('%s_%s_%s.sql', $remoteDatabase, $timestamp, uniqid());

        $command = sprintf('ssh %s@%s "mysqldump %s > %s"', $remoteUser, $remoteHost, $remoteDatabase, $fileName);
        $helper->comment($command);

        $process = new Process($command);
        $process->setTimeout(600);

        $process->run(function ($type, $buffer) use ($helper) {
            if (Process::ERR === $type) {
                $helper->error($buffer);

                if (false !== strpos($buffer, 'Access denied')) {
                    $helper->note('Missing .my.cnf for mysql access?');
                }
            } else {
                $helper->comment($buffer);
            }
        });

        /*
         * scp
         */
        $command = sprintf('scp %s@%s:%s %s/%s', $remoteUser, $remoteHost, $fileName, sys_get_temp_dir(), $fileName);
        $helper->comment($command);

        $process = new Process($command);
        $process->setTimeout(300);

        $process->run(function ($type, $buffer) use ($helper) {
            if (Process::ERR === $type) {
                $helper->error($buffer);
            } else {
                $helper->comment($buffer);
            }
        });

        /*
         * create database database_name_ymdHis
         * if exists: ask for drop
         */
        $command = sprintf('mysql -h%s -u%s -e "CREATE DATABASE %s;"', $localDatabaseHost, $localDatabaseUser, $localDatabaseName);
        $helper->comment($command);

        $process = new Process($command);
        $process->run(function ($type, $buffer) use ($helper) {
            if (Process::ERR === $type) {
                $helper->error($buffer);

                if (false !== strpos($buffer, 'Access denied')) {
                    $helper->note('Missing .my.cnf for mysql access?');
                }
            } else {
                $helper->comment($buffer);
            }
        });

        /*
         * mysql -D database_name_ymdhis < /backup/y-m-d_H-i-s_unique.sql
         */
        $command = sprintf('mysql -h%s -u%s  -D %s < %s/%s', $localDatabaseHost, $localDatabaseUser, $localDatabaseName, sys_get_temp_dir(), $fileName);
        $helper->comment($command);

        $process = new Process($command);
        $process->setTimeout(3600);

        $process->run(function ($type, $buffer) use ($helper) {
            if (Process::ERR === $type) {
                $helper->error($buffer);
            } else {
                $helper->comment($buffer);
            }
        });

        /**
         * Remove
         */
        $command = sprintf('ssh %s "rm %s"', $remoteHost, $fileName);
        $helper->comment($command);

        $process = new Process($command);
        $process->run(function ($type, $buffer) use ($helper) {
            if (Process::ERR === $type) {
                $helper->error($buffer);
            } else {
                $helper->comment($buffer);
            }
        });

        $command = sprintf('%s/%s', sys_get_temp_dir(), $fileName);
        $helper->comment(sprintf('unlink %s', $command));
        unlink($command);

        /**
         * Success! New database name:
         */
        $helper->success(
            [
                'Created new Database',
                $localDatabaseName,
            ]
        );

        return null;
    }
1356469
def _update_database_helper_table(
            self):
        
        self.log.debug('starting the ``_update_database_helper_table`` method')

        tableName = self.dbTableName

        sqlQuery = u"""
            update tcs_helper_catalogue_tables_info set last_updated = now() where table_name = "%(tableName)s";
        """ % locals()

        writequery(
            log=self.log,
            sqlQuery=sqlQuery,
            dbConn=self.cataloguesDbConn,
        )

        self.log.debug(
            'completed the ``_update_database_helper_table`` method')
        return None
765691
public void doOpen() throws DBException
    {
        try   {
    // FROM is automatic, since the remote BaseRecord is exactly the same as this one
    // ORDER BY
            KeyArea keyArea = this.getRecord().getKeyArea(-1);  // Current index
            String strKeyArea = null;
            boolean bDirection = DBConstants.ASCENDING;
            if (true)
            {
                strKeyArea = keyArea.getKeyName();
                bDirection = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getKeyOrder();
            }
            m_bDirectionCurrent = bDirection;
    // Open mode
            int iOpenMode = this.getRecord().getOpenMode();
    // SELECT (fields to select)
            String strFields = null;
            if (true) // All selected?
            {
                strFields = this.getRecord().getSQLFields(DBConstants.SQL_SELECT_TYPE, true);
                if (strFields.equals(" *"))
                    strFields = null; // Select all
            }
    // WHERE XYZ >=
            Object objInitialKey = null;
            if (true)
            {
                BaseBuffer buffer = new VectorBuffer(null);
                this.getRecord().handleInitialKey();
                if (keyArea.isModified(DBConstants.START_SELECT_KEY))
                {   // Anything set?
                    keyArea.setupKeyBuffer(buffer, DBConstants.START_SELECT_KEY, false);
                    objInitialKey = buffer.getPhysicalData();
                    buffer.addNextString(Integer.toString(keyArea.lastModified(DBConstants.START_SELECT_KEY, false))); // Largest modified field.
                }
            }
    // WHERE XYZ <=
            Object objEndKey = null;
            if (true)
            {
                BaseBuffer buffer = new VectorBuffer(null);
                this.getRecord().handleEndKey();
                if (keyArea.isModified(DBConstants.END_SELECT_KEY))
                {   // Anything set?
                    keyArea.setupKeyBuffer(buffer, DBConstants.END_SELECT_KEY, false);
                    objEndKey = buffer.getPhysicalData();
                    buffer.addNextString(Integer.toString(keyArea.lastModified(DBConstants.END_SELECT_KEY, false))); // Largest modified field.
                }
            }
    // WHERE XYZ
            byte[] byBehaviorData = null;
            boolean bDirty = false;
            if (this.getRecord().getListener() != null)
            {
                ByteArrayOutputStream baOut = new ByteArrayOutputStream();
                ObjectOutputStream daOut = new ObjectOutputStream(baOut);
                FileListener listener = (FileListener)this.getRecord().getListener();
                while (listener != null)
                {
                    if ((listener.getMasterSlaveFlag() & FileListener.RUN_IN_SLAVE) != 0) // Should exist in a SERVER environment
                        if ((listener.getMasterSlaveFlag() & FileListener.DONT_REPLICATE_TO_SLAVE) == 0) // Yes, replicate to the SERVER environment
                            if (listener.isEnabledListener()) // Yes, only replicate enabled listeners.
                    { // There should be a copy of this on the server
                        bDirty = true;
                        daOut.writeUTF(listener.getClass().getName());
                        listener.initRemoteStub(daOut);
                    }
                    listener = (FileListener)listener.getNextListener();
                }
                daOut.flush();
                if (bDirty)
                    byBehaviorData = baOut.toByteArray();
                daOut.close();
                baOut.close();
            }

            this.checkCacheMode(Boolean.TRUE);      // Make sure the cache is set up correctly for this type of query (typically needed)

            synchronized (this.getSyncObject())
            {   // In case this is called from another task
                m_tableRemote.open(strKeyArea, iOpenMode, bDirection, strFields, objInitialKey, objEndKey, byBehaviorData);
            }
        } catch (Exception ex) {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
24700
def db_putString(self, db_name, key, value):
        
        warnings.warn('deprecated', DeprecationWarning)
        return (yield from self.rpc_call('db_putString',
                                         [db_name, key, value]))
123325
def method_missing(name, *args, &blk)
      if name.to_s =~ /^default_(.*)=$/
        @default_options[$1.to_sym] = args.first
      elsif name.to_s =~ /=$/
        @dirty_options[$`.to_sym] = args.first
      elsif @default_options.key?(name)
        dirty_or_db_setting_or_default(name)
      else
        super
      end
    end
965740
function replaceFieldNames(sql, identifiers, model) {
	const {queryInterface} = model.sequelize;
	_.forIn(identifiers, (fieldName, identifier) => {
		// Get table field name for model field
		fieldName = (model.rawAttributes || model.attributes)[fieldName].field;

		// Replace identifiers
		sql = sql.replace(
			new RegExp(`\\*${identifier}(?![a-zA-Z0-9_])`, 'g'),
			queryInterface.quoteIdentifier(fieldName)
		);
	});
	return sql;
}
22611
@Deprecated
    public static Object getObjectIndex(Object obj, double dblIndex,
                                        Context cx)
    {
        return getObjectIndex(obj, dblIndex, cx, getTopCallScope(cx));
    }
1358099
function OriginDB(name, options) {
  let objects = {};
  let checksums = {};

  if (!_.isString(name)) {
    throw new Error('Invalid name');
  }

  if (_.isObject(options)) {
    options = Object.assign({}, defaultOptions, options);
  } else {
    options = defaultOptions;
  }

  if (_.isString(options.adapter) && !_.has(adapters, options.adapter)) {
    throw new Error('Unknown adapter');
  }

  const save = _.isFunction(options.adapter) ?
    options.adapter(name, objects, checksums, options) :
    adapters[options.adapter](name, objects, checksums, options);

  /**
   * The database instance.
   *
   * @param {string} objectName
   * @param {Object} methods
   */
  function db(objectName) {
    if (_.isBoolean(save.hasLoaded)) deasync.loopWhile(() => !save.hasLoaded);
    if (!_.has(objects, objectName)) objects[objectName] = {};
    return createMethods(objects[objectName], save.bind(null, objectName));
  }

  // backwards compatability with < v2.4.1
  db.save = () => {
    if (_.isBoolean(save.hasLoaded)) deasync.loopWhile(() => !save.hasLoaded);
    _.forIn(objects, function(value, file) {
      save(file);
    });
  };

  return db;
}