For each sql script that needs to be applied to this database,
 yields a pair of |filename, fullpath| in proper order

 db = Db.new(host, user, name)
 scripts = Scripts.new(db)
 scripts.each_pending do |filename, path|
    puts filename
 end
333078
def each_pending(dir)
      files = {}
      Scripts.all(dir).each do |path|
        name = File.basename(path)
        files[name] = path
      end

      scripts_previously_run(files.keys).each do |filename|
        files.delete(filename)
      end

      files.keys.sort.each do |filename|
        ## We have to recheck if this script is still pending. Some
        ## upgrade scripts may modify the scripts table themselves. This
        ## is actually useful in cases like when we migrated gilt from
        ## util_schema => schema_evolution_manager schema
        if !has_run?(filename)
          yield filename, files[filename]
        end
      end
    end
507870
def sql_connection(options={}, &block)
      @sql_connection ||= Mongify::Database::SqlConnection.new(options)
      @sql_connection.instance_exec(&block) if block_given?
      @sql_connection
    end
916404
def write_db
      new_db = {}
      @db.keys.sort.each do |key|
        new_db[key] = {}
        Braid::Mirror::ATTRIBUTES.each do |k|
          new_db[key][k] = @db[key][k] if @db[key].has_key?(k)
        end
      end
      new_data = {
        'config_version' => CURRENT_CONFIG_VERSION,
        'mirrors' => new_db
      }
      File.open(@config_file, 'wb') do |f|
        f.write JSON.pretty_generate(new_data)
        f.write "\n"
      end
    end
1369710
def getScriptNames(self):
		""""""

		if self._db == '':
			raise FMError, 'No database was selected'

		request = []
		request.append(uu({'-db': self._db }))
		request.append(uu({'-scriptnames': '' }))

		result = self._doRequest(request)
		result = FMResultset.FMResultset(result)

		scriptNames = []
		for scriptName in result.resultset:
			scriptNames.append(string.lower(scriptName['SCRIPT_NAME']))

		return scriptNames
637946
def prepopulate(self):
        
        if self._prepopulated is False:
            engine = create_engine('sqlite:////' + self.dbpath)
            self._db_base.metadata.create_all(engine)
            self._prepopulated = True
            session_cl = sessionmaker(bind=engine)
            session = session_cl()

            for (dirpath, dirnames, filenames) in walk(self.path_to_set):
                for f_name in filenames:
                    datapoint = self._set_object(real_id=cutoff_filename(self.file_prefix, self.file_suffix, f_name),
                                                 path=f_name, features=None)
                    session.add(datapoint)
                    self.points_amt += 1
            session.commit()
            session.close()
        return None
1071393
def load_all
      return unless @file
      return if @loaded_objects >= @available_objects
      log.debug "Loading entire database: #{@file} ..."
      objects = []

      all_disk_objects.sort_by(&:size).each do |path|
        obj = @serializer.deserialize(path, true)
        objects << obj if obj
      end

      objects.each do |obj|
        put(obj.path, obj)
      end

      @loaded_objects += objects.size
      log.debug "Loaded database (file='#{@file}' count=#{objects.size} total=#{@available_objects})"
    end
164023
def instantiate_database(sqlite_file='ftwj.sqlite'):
    
    table_name = 'ftw'
    col1 = 'rule_id'
    col1_t = 'INTEGER'
    col2 = 'test_id'
    col2_t = 'STRING'
    col3 = 'time_start'
    col3_t = 'TEXT'
    col4 = 'time_end'
    col4_t = 'TEXT'
    col5 = 'response_blob'
    col5_t = 'TEXT'
    col6 = 'status_code'
    col6_t = 'INTEGER'
    col7 = 'stage'
    col7_t = 'INTEGER'
    conn = sqlite3.connect(sqlite_file)
    cur = conn.cursor()

    q = 'CREATE TABLE {tn}({col1} {col1_t},{col2} {col2_t},{col3} {col3_t},{col4} {col4_t},{col5} {col5_t},{col6} {col6_t},{col7} {col7_t})'.format(
        tn=table_name,
        col1=col1, col1_t=col1_t,
        col2=col2, col2_t=col2_t,
        col3=col3, col3_t=col3_t,
        col4=col4, col4_t=col4_t,
        col5=col5, col5_t=col5_t,
        col6=col6, col6_t=col6_t,
        col7=col7, col7_t=col7_t)
    cur.execute(q)
    conn.commit()
    conn.close()
1253366
public function prepare()
  {
    $initFile=$this->basePath . DIRECTORY_SEPARATOR . $this->initScript;

    $this->checkIntegrity(false); //not supported in sqlite

    if(is_file($initFile))
      require($initFile);
    else
    {
      foreach($this->getFixtures() as $tableName=>$fixturePath)
      {
        $this->resetTable($tableName);
        $this->loadFixture($tableName);
      }
    }
    $this->checkIntegrity(true); //not supported in sqlite
  }
1139340
public static void executeDatabaseScript(String script) throws SQLException, MalformedURLException {
        File file = new File(script);
        DatabaseUtils.executeSqlScript(DatabaseUtils.getDBConnection(null), file.toURI().toURL());
    }
1288919
def gen_fetchall(self, sql: str, *args) -> Iterator[Sequence[Any]]:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        self.db_exec_with_cursor(cursor, sql, *args)
        try:
            row = cursor.fetchone()
            while row is not None:
                yield row
                row = cursor.fetchone()
        except:  # nopep8
            log.exception("gen_fetchall: SQL was: " + sql)
            raise
605966
def each
      generator_full_paths.each do |generator|
        yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
      end
    end
1328548
def init_db(self):
        '''
        '''
        cache_path = os.path.join(Config.CACHE_DIR,
                                  self.app.profile['username'])
        if not os.path.exists(cache_path):
            os.makedirs(cache_path, exist_ok=True)
        db = os.path.join(cache_path, TASK_FILE)
        self.conn = sqlite3.connect(db)
        self.cursor = self.conn.cursor()
        sql = '''CREATE TABLE IF NOT EXISTS tasks (
        name CHAR NOT NULL,
        path CHAR NOT NULL,
        fsid CHAR NOT NULL,
        size INTEGER NOT NULL,
        currsize INTEGER NOT NULL,
        link CHAR,
        isdir INTEGER,
        savename CHAR NOT NULL,
        savedir CHAR NOT NULL,
        state INT NOT NULL,
        statename CHAR NOT NULL,
        humansize CHAR NOT NULL,
        percent INT NOT NULL,
        tooltip CHAR
        )
        '''
        self.cursor.execute(sql)
120656
def compile(self, db):
        
        sql = self.expression
        if self.alias:
            sql += (' AS ' + db.quote_column(self.alias))
        return sql
673658
def fetchall_with_fieldnames(self, sql: str, *args) \
            -> Tuple[Sequence[Sequence[Any]], Sequence[str]]:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        self.db_exec_with_cursor(cursor, sql, *args)
        try:
            rows = cursor.fetchall()
            fieldnames = [i[0] for i in cursor.description]
            return rows, fieldnames
        except:  # nopep8
            log.exception("fetchall_with_fieldnames: SQL was: " + sql)
            raise
56178
function (i) {
                    if (i >= columns.length) {
                        insertIntoDB();
                        return;
                    }

                    var dbField = columns[i];
                    var field = dbField.Field;

                    //Check required fields
                    if (dbField.Null === 'NO' && 
                        dbField.Default === '' && 
                        dbField.Extra !== 'auto_increment' && 
                        dbField.Extra.search('on update')===-1) {

                        //Check if field not set
                        if (undefOrEmpty(req.body[field])) {
                            return sendError(res,"Field " + field + " is NOT NULL but not specified in this request");
                        } else {
                            //Check if the set values are roughly okay
                            value = checkIfSentvaluesAreSufficient(req,dbField);
                            console.log(value);
                            if(value !== false) {
                                //Value seems okay, go to the next field
                                insertJson[field] = value;
                                iterator(i + 1);
                            } else {
                                return sendError(res,'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field] );
                            }
                        }
                    }  else {
                        //Check for not required fields
                        //Skip auto_incremented fields
                        if(dbField.Extra === 'auto_increment') {
                            iterator(i + 1);
                        } else {
                            //Check if the field was provided by the client
                            var defined = false;
                            if(dbField.Default == "FILE") {
                                if(req.files.hasOwnProperty(dbField.Field)) {
                                    defined = true;
                                }
                            } else {
                                if(typeof req.body[field] !== "undefined") {
                                    defined = true;
                                }
                            }

                            //If it was provided, check if the values are okay
                            if(defined) {
                                value = checkIfSentvaluesAreSufficient(req,dbField);
                                if(value !== false) {
                                    insertJson[field] = value;
                                    iterator(i + 1);
                                } else {
                                    if(dbField.Default == "FILE") {
                                        return sendError(res, 'Value for field ' + field + ' is not sufficient. Either the file is to large or an other error occured');
                                    } else {
                                        return sendError(res, 'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field]);
                                    }
                                }
                            } else {
                                //If not, don't mind
                                iterator(i + 1);
                            }

                        }
                    }

                }
1281385
def __run_pre_all(self):
        """"""

        # if the list of delta dirs is [delta1, delta2] the pre scripts of delta2 are
        # executed before the pre scripts of delta1

        for d in reversed(self.dirs):
            pre_all_py_path = os.path.join(d, 'pre-all.py')
            if os.path.isfile(pre_all_py_path):
                print('     Applying pre-all.py...', end=' ')
                self.__run_py_file(pre_all_py_path, 'pre-all')
                print('OK')

            pre_all_sql_path = os.path.join(d, 'pre-all.sql')
            if os.path.isfile(pre_all_sql_path):
                print('     Applying pre-all.sql...', end=' ')
                self.__run_sql_file(pre_all_sql_path)
                print('OK')
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
  ];
}