Reads the content of the database file and returns imported data.
505315
def import_sqlite(db_file, older_than=None, **kwargs):
    """"""
    conn = _open_sqlite(db_file)
    cur = conn.cursor()
    # get rows that were not exported yet
    select = "SELECT * FROM testcases WHERE exported != 'yes'"
    if older_than:
        cur.execute(" ".join((select, "AND sqltime < ?")), (older_than,))
    else:
        cur.execute(select)
    columns = [description[0] for description in cur.description]
    rows = cur.fetchall()

    # map data to columns
    results = []
    for row in rows:
        record = OrderedDict(list(zip(columns, row)))
        results.append(record)

    testrun = _get_testrun_from_sqlite(conn)

    conn.close()

    return xunit_exporter.ImportedData(results=results, testrun=testrun)
368577
def _load(self):
        
        if self.dbfile is not None:
            with open(self.dbfile, 'r') as f:
                self._db = json.loads(f.read())
        else:
            self._db = {}
70608
private synchronized void init() throws IOException {
        if (file == null) {
            return;
        }
        if ((dboptions & GEOIP_CHECK_CACHE) != 0) {
            mtime = databaseFile.lastModified();
        }
        file.seek(file.length() - 3);
        byte[] delim = new byte[3];
        byte[] buf = new byte[SEGMENT_RECORD_LENGTH];
        for (int i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) {
            file.readFully(delim);
            if (delim[0] == -1 && delim[1] == -1 && delim[2] == -1) {
                databaseType = file.readByte();
                if (databaseType >= 106) {
                    // Backward compatibility with databases from April 2003 and
                    // earlier
                    databaseType -= 105;
                }
                // Determine the database type.
                if (databaseType == DatabaseInfo.REGION_EDITION_REV0) {
                    databaseSegments = new int[1];
                    databaseSegments[0] = STATE_BEGIN_REV0;
                    recordLength = STANDARD_RECORD_LENGTH;
                } else if (databaseType == DatabaseInfo.REGION_EDITION_REV1) {
                    databaseSegments = new int[1];
                    databaseSegments[0] = STATE_BEGIN_REV1;
                    recordLength = STANDARD_RECORD_LENGTH;
                } else if (databaseType == DatabaseInfo.CITY_EDITION_REV0
                        || databaseType == DatabaseInfo.CITY_EDITION_REV1
                        || databaseType == DatabaseInfo.ORG_EDITION
                        || databaseType == DatabaseInfo.ORG_EDITION_V6
                        || databaseType == DatabaseInfo.ISP_EDITION
                        || databaseType == DatabaseInfo.ISP_EDITION_V6
                        || databaseType == DatabaseInfo.DOMAIN_EDITION
                        || databaseType == DatabaseInfo.DOMAIN_EDITION_V6
                        || databaseType == DatabaseInfo.ASNUM_EDITION
                        || databaseType == DatabaseInfo.ASNUM_EDITION_V6
                        || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1
                        || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1_V6
                        || databaseType == DatabaseInfo.CITY_EDITION_REV0_V6
                        || databaseType == DatabaseInfo.CITY_EDITION_REV1_V6) {
                    databaseSegments = new int[1];
                    databaseSegments[0] = 0;
                    if (databaseType == DatabaseInfo.CITY_EDITION_REV0
                            || databaseType == DatabaseInfo.CITY_EDITION_REV1
                            || databaseType == DatabaseInfo.ASNUM_EDITION_V6
                            || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1
                            || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1_V6
                            || databaseType == DatabaseInfo.CITY_EDITION_REV0_V6
                            || databaseType == DatabaseInfo.CITY_EDITION_REV1_V6
                            || databaseType == DatabaseInfo.ASNUM_EDITION) {
                        recordLength = STANDARD_RECORD_LENGTH;
                    } else {
                        recordLength = ORG_RECORD_LENGTH;
                    }
                    file.readFully(buf);
                    for (int j = 0; j < SEGMENT_RECORD_LENGTH; j++) {
                        databaseSegments[0] += (unsignedByteToInt(buf[j]) << (j * 8));
                    }
                }
                break;
            } else {
                file.seek(file.getFilePointer() - 4);
            }
        }
        if ((databaseType == DatabaseInfo.COUNTRY_EDITION)
                || (databaseType == DatabaseInfo.COUNTRY_EDITION_V6)
                || (databaseType == DatabaseInfo.PROXY_EDITION)
                || (databaseType == DatabaseInfo.NETSPEED_EDITION)) {
            databaseSegments = new int[1];
            databaseSegments[0] = COUNTRY_BEGIN;
            recordLength = STANDARD_RECORD_LENGTH;
        }
        if ((dboptions & GEOIP_MEMORY_CACHE) == 1) {
            int l = (int) file.length();
            dbbuffer = new byte[l];
            file.seek(0);
            file.readFully(dbbuffer, 0, l);
            databaseInfo = getDatabaseInfo();
            file.close();
        }
        if ((dboptions & GEOIP_INDEX_CACHE) != 0) {
            int l = databaseSegments[0] * recordLength * 2;
            index_cache = new byte[l];
            file.seek(0);
            file.readFully(index_cache, 0, l);
        } else {
            index_cache = null;
        }
    }
240207
def _loadDB(self):
        """"""
        if not self._validID():
            raise NotFound, self._getID()
        (sql, fields) = self._prepareSQL("SELECT")
        curs = self.cursor()
        curs.execute(sql, self._getID())
        result = curs.fetchone()
        if not result:
            curs.close()
            raise NotFound, self._getID()
        self._loadFromRow(result, fields, curs)
        curs.close()
        self._updated = time.time()
678202
def read(database, table, key):
    """"""
    with database.snapshot() as snapshot:
        result = snapshot.execute_sql('SELECT u.* FROM %s u WHERE u.id="%s"' %
                                      (table, key))
        for row in result:
            key = row[0]
        for i in range(NUM_FIELD):
            field = row[i + 1]
703045
def parse(db_folder, out_folder):
    
    # The database structure, containing table and column definitions as
    # well as other data.
    stru_dat = get_file(db_folder, 'CroStru.dat')
    # Index file for the database, which contains offsets for each record.
    data_tad = get_file(db_folder, 'CroBank.tad')
    # Actual data records, can only be decoded using CroBank.tad.
    data_dat = get_file(db_folder, 'CroBank.dat')
    if None in [stru_dat, data_tad, data_dat]:
        raise CronosException("Not all database files are present.")

    meta, tables = parse_structure(stru_dat)

    for table in tables:
        # TODO: do we want to export the "FL" table?
        if table['abbr'] == 'FL' and table['name'] == 'Files':
            continue
        fh = open(make_csv_file_name(meta, table, out_folder), 'w')
        columns = table.get('columns')
        writer = csv.writer(fh)
        writer.writerow([encode_cell(c['name']) for c in columns])
        for row in parse_data(data_tad, data_dat, table.get('id'), columns):
            writer.writerow([encode_cell(c) for c in row])
        fh.close()
988633
public function import_database() {
        $parser = $this->get_parser();
        if (!xml_parse($parser, $this->data, true)) {
            throw new dbtransfer_exception('malformedxmlexception');
        }
        xml_parser_free($parser);
    }
951687
def get_imported_data(csv_file, **kwargs):
    """"""
    open_args = []
    open_kwargs = {}
    try:
        # pylint: disable=pointless-statement
        unicode
        open_args.append("rb")
    except NameError:
        open_kwargs["encoding"] = "utf-8"
    with open(os.path.expanduser(csv_file), *open_args, **open_kwargs) as input_file:
        reader = _get_csv_reader(input_file)

        fieldnames = _get_csv_fieldnames(reader)
        if not fieldnames:
            raise Dump2PolarionException(
                "Cannot find field names in CSV file '{}'".format(csv_file)
            )

        results = _get_results(reader, fieldnames)
        if not results:
            raise Dump2PolarionException("No results read from CSV file '{}'".format(csv_file))

        testrun = _get_testrun_from_csv(input_file, reader)

    return xunit_exporter.ImportedData(results=results, testrun=testrun)
30366
private void fetchImportedKeys() {

        Vector imKeys      = new Vector(20);
        Vector imKeyNames  = null;
        Vector refTabs     = new Vector(20);
        Vector refCols     = new Vector(20);
        Vector refColNames = null;

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getImportedKeys(null, null, tableName);
            String    pkTable, pkColumn, fkColumn;
            int       keySeq;

            while (colList.next()) {
                pkTable  = colList.getString("PKTABLE_NAME");
                pkColumn = colList.getString("PKCOLUMN_NAME");
                fkColumn = colList.getString("FKCOLUMN_NAME");
                keySeq   = colList.getInt("KEY_SEQ");

                if (keySeq == 1) {
                    if (imKeyNames != null) {
                        imKeys.addElement(imKeyNames);
                        refCols.addElement(refColNames);
                    }    // end of if (exKeyNames != null)

                    imKeyNames  = new Vector(20);
                    refColNames = new Vector(20);

                    refTabs.addElement(pkTable);
                }        // end of if (keySeq == 1)

                imKeyNames.addElement(fkColumn);
                refColNames.addElement(pkColumn);
            }

            if (imKeyNames != null) {
                imKeys.addElement(imKeyNames);
                refCols.addElement(refColNames);
            }            // end of if (exKeyNames != null)

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        // System.out.println("Imported Keys of "+tableName);
        int numberOfConstraints = imKeys.size();

        importedKeys = new String[numberOfConstraints][];
        imColIndex   = new int[numberOfConstraints][];
        refTables    = new String[numberOfConstraints];
        refColumns   = new String[numberOfConstraints][];
        refColIndex  = new int[numberOfConstraints][];

        for (int i = 0; i < numberOfConstraints; i++) {
            Vector keys         = (Vector) imKeys.elementAt(i);
            Vector cols         = (Vector) refCols.elementAt(i);
            int    numberOfKeys = keys.size();

            importedKeys[i] = new String[numberOfKeys];
            imColIndex[i]   = new int[numberOfKeys];
            refColumns[i]   = new String[numberOfKeys];
            refColIndex[i]  = new int[numberOfKeys];
            refTables[i]    = (String) refTabs.elementAt(i);

            // System.out.println("reference table "+refTables[i]);
            for (int j = 0; j < numberOfKeys; j++) {
                importedKeys[i][j] = (String) keys.elementAt(j);
                imColIndex[i][j]   = this.getColIndex(importedKeys[i][j]);
                refColumns[i][j]   = (String) cols.elementAt(j);
                refColIndex[i][j] = this.getColIndex(refColumns[i][j],
                                                     refTables[i]);

                // System.out.println("   importedKeys "+importedKeys[i][j]+"(Index: "+imColIndex[i][j]+") refColumns "+refColumns[i][j]+"(Index: "+refColIndex[i][j]+")");
            }    // end of for (int j=0; j<numberOfKeys; j++)
        }
    }
68044
def _load_data(self, data, from_db=False):
        
        self._data = data[:]
        self.setattrs(
            values=[],
            node_stack=[],
            node_dict={},
        )
        self._from_db = from_db
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)
456129
private boolean importDatabase(String sender) {
        PreparedStatement statement = null;
        try {
            statement = connect.prepareStatement("SELECT * FROM fe_accounts");
            ResultSet rs = statement.executeQuery();
            List<User> userList = new ArrayList<>();
            while (rs.next()) {
                userList.add(new User(rs.getString("name"), rs.getDouble("money")));
            }
            rs.close();
            addAccountToString(sender, userList);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            Tools.closeJDBCStatement(statement);
            Tools.closeJDBCConnection(connect);
        }
        return true;
    }
704424
def read(self):
        """"""
        data = bytearray()
        while True:
            incoming_bytes = self.comport.inWaiting()
            if incoming_bytes == 0:
                break
            else:
                content = self.comport.read(size=incoming_bytes)
                data.extend(bytearray(content))
        return data
1363047
def __load_countries(self, db):
        """"""

        try:
            countries = self.__read_countries_file()
        except IOError as e:
            raise LoadError(str(e))

        try:
            with db.connect() as session:
                for country in countries:
                    session.add(country)
        except Exception as e:
            raise LoadError(str(e))
1279054
def readddl(db):
    ''''''
    jdoc = []
    for schema in db.contents:
        j = JDOC(None,
                 schema.object_name,
                 schema.comment,
                 schema.object_type)
        jdoc.append(j)
        for table in schema.contents:
            j = JDOC(table.schema_name,
                     table.object_name,
                     table.comment,
                     table.object_type)
            for c in table.contents:
                j.params.append(c)
            jdoc.append(j)
    return jdoc
1344592
public static int importData(final DataSet dataset, final PreparedStatement stmt) throws UncheckedSQLException {
        return importData(dataset, dataset.columnNameList(), stmt);
    }
1362198
protected function read()
    {
        $handle = fopen($this->config['path'], "r");

        if (!$handle)
            throw new ImportException('Unable to open file, or file not exist');

        if (!$this->import->CheckIfFileIsCML($this->config['path'])) {
            throw new ImportException('File is not valid');
        }

        $this->xml->DropTemporaryTables();
        $this->xml->CreateTemporaryTables();
        $this->xml->ReadXMLToDatabase($handle, $this->session, $this->config['interval']);
        $this->xml->IndexTemporaryTables();
    }