Load necessary resources tables into db to execute given query.
17142
def load_tables(self, query, meta):
        
        try:
            for table in meta.tables:
                self.load_table(table)
        except NoCredentialsError:
            help_link = 'http://boto3.readthedocs.io/en/latest/guide/configuration.html'
            raise QueryError('Unable to locate AWS credential. '
                             'Please see {0} on how to configure AWS credential.'.format(help_link))
714571
public void loadDatabaseProperties()
    {
        if (this.getProperty(STARTING_ID) != null)
            return; // Already read (This value will be cached in the environment database cache)
        int iStartID = 1;
        /* This code works, but I prefer to use the DatabaseInfo record.
        try {
            Statement queryStatement = this.getJDBCConnection().createStatement();
    
            String strSQL = "select StartID from DatabaseInfo where ID=1;";
            queryStatement.execute(strSQL);
            
            ResultSet resultset = queryStatement.getResultSet();
            boolean more = resultset.next();
            if (more)
            {
                iStartID = resultset.getInt(1);
            }
            resultset.close();
            queryStatement.close();
        } catch (SQLException e) {
            // Ignore table not found error.
        }
        */
    	if ((this.getDatabaseType() & (DBConstants.SHARED_DATA | DBConstants.USER_DATA)) != DBConstants.SHARED_DATA)
    		return;		// DatabaseInfo would only exist for shared databases

    	RecordOwner recordOwner = null; // ((BaseApplication)this.getDatabaseOwner().getEnvironment().getDefaultApplication()).getMainTask().; // For now
        DatabaseInfo recDatabaseInfo = new DatabaseInfo();
        recDatabaseInfo.setTable(this.doMakeTable(recDatabaseInfo));    // This makes a jdbc table
        String dbName = this.getDatabaseName(true);
        if (dbName.endsWith(SHARED_SUFFIX))
        	dbName = dbName.substring(0, dbName.length() - SHARED_SUFFIX.length());	// Always
        else if (dbName.endsWith(USER_SUFFIX))
        	dbName = dbName.substring(0, dbName.length() - USER_SUFFIX.length());	// Never
        recDatabaseInfo.setDatabaseName(dbName);

        int iOldOpenMode = recDatabaseInfo.getOpenMode();
        //x recDatabaseInfo.setOpenMode(recDatabaseInfo.getOpenMode() | DBConstants.OPEN_DONT_CREATE); // Removed 

        recDatabaseInfo.init(recordOwner);

        recDatabaseInfo.setOpenMode(iOldOpenMode);
        
        if (recDatabaseInfo.getEditMode() == DBConstants.EDIT_CURRENT)
        {
            iStartID = (int)recDatabaseInfo.getField(DatabaseInfo.START_ID).getValue();
            if (!recDatabaseInfo.getField(DatabaseInfo.END_ID).isNull())
                this.addDatabaseProperty(ENDING_ID, Integer.toString((int)recDatabaseInfo.getField(DatabaseInfo.END_ID).getValue()));
            if (!recDatabaseInfo.getField(DatabaseInfo.BASE_DATABASE).isNull())
                this.addDatabaseProperty(BaseDatabase.BASE_DATABASE, recDatabaseInfo.getField(DatabaseInfo.BASE_DATABASE).toString());
        }
        if (iStartID <= 0)
            iStartID = 1;
        recDatabaseInfo.free();
        this.addDatabaseProperty(STARTING_ID, Integer.toString(iStartID));
        
        if (m_databaseBase == null) // Always
            if (this.getProperty(BASE_DATABASE) != null)
        {
            Map<String,Object> properties = new HashMap<String,Object>();
            properties.putAll(this.getProperties());
            properties.remove(BASE_DATABASE);
            properties.put(BASE_DATABASE_JDBC_DRIVER, properties.remove(SQLParams.JDBC_DRIVER_PARAM));
            properties.put(DBConstants.DB_USER_PREFIX, DBConstants.BLANK);
            properties.remove(DBConstants.SYSTEM_NAME);
            properties.put(DBConstants.MODE, DBConstants.BLANK);
            m_databaseBase = (BaseDatabase)m_databaseOwner.getDatabase(this.getProperty(BASE_DATABASE), this.getDatabaseType() & DBConstants.TABLE_MASK, properties);
        }
    }
64281
def execute_sql(self, query):
        
        c = self.con.cursor()
        c.execute(query)
        result = c.fetchall()
        return result
1130580
private function loadAll(): void
  {
    $this->findSourceFiles();
    $this->detectNameConflicts();
    $this->getColumnTypes();
    $this->readStoredRoutineMetadata();
    $this->getConstants();
    $this->getOldStoredRoutinesInfo();
    $this->getCorrectSqlMode();

    $this->loadStoredRoutines();

    // Drop obsolete stored routines.
    $this->dropObsoleteRoutines();

    // Remove metadata of stored routines that have been removed.
    $this->removeObsoleteMetadata();

    $this->io->writeln('');

    // Write the metadata to file.
    $this->writeStoredRoutineMetadata();
  }
828714
public void execute() {
        try {
            new JdbcTemplate(dataSource).execute(readResourceContent(SCHEMA_FILE)); // TODO: sql independence
        } catch (IOException e) {
            throw new RuntimeException("Could not create schema for EDBI Index", e);
        }
    }
490436
def execute_query(self, query, values):
        
        retval = self.cursor.execute(query, values)
        self.__close_db()
        return retval
1009705
def load_output(self, args, kwargs):
        """"""
        return db.find(self.get_output_key(args, kwargs))
884981
def _run_init_queries(self):
        '''
        
        '''
        for obj in (Package, PackageCfgFile, PayloadFile, IgnoredDir, AllowedDir):
            self._db.create_table_from_object(obj())
383518
def _load_resource(self):
        """"""

        url = self._url
        if self._params:
            url += '?{0}'.format(six.moves.urllib_parse.urlencode(self._params))

        r = getattr(self._session, self._meta.get_method.lower())(url)

        if r.status_code == 404:
            raise NotFoundException('Server returned 404 Not Found for the URL {0}'.format(self._url))
        elif not 200 <= r.status_code < 400:
            raise HTTPException('Server returned {0} ({1})'.format(r.status_code, r.reason), r)

        data = self._meta.deserializer.to_dict(r.text)
        self.populate_field_values(data)
869599
def execute(self, sql, values = ()) :
		""
		sql = sql.strip()
		self._debugActions(sql, values)
		cur = self.connection.cursor()
		cur.execute(sql, values)
		return cur
1249775
def execute_sql(self, sql, commit=False):
        """"""
        logger.info("Running sqlite query: \"%s\"", sql)
        self.connection.execute(sql)
        if commit:
            self.connection.commit()
681960
private ResultSet executeQuery(Query query, String tableName, Object... values) {
        m_logger.debug("Executing statement {} on table {}.{}; total params={}",
                       new Object[]{query, m_keyspace, tableName, values.length});
        try {
            PreparedStatement prepState = getPreparedQuery(query, tableName);
            BoundStatement boundState = prepState.bind(values);
            return m_session.execute(boundState);
        } catch (Exception e) {
            String params = "[" + Utils.concatenate(Arrays.asList(values), ",") + "]";
            m_logger.error("Query failed: query={}, keyspace={}, table={}, params={}; error: {}",
                           query, m_keyspace, tableName, params, e);
            throw e;
        }
    }
894743
@Override
    public DataSet executeQuery(String query) throws JdbcServerException {
        log.info("Received execute query request: " + query);
        Message response = handleMessageAndCheckResponse(JdbcMessage.execute(query));
        return dataSetCreator.createDataSet(response, getMessageType(response));
    }
1258295
def _execute_select_commands(self, source, commands):
        """"""
        rows = {}
        for tbl, command in tqdm(commands, total=len(commands), desc='Executing {0} select queries'.format(source)):
            # Add key to dictionary
            if tbl not in rows:
                rows[tbl] = []
            rows[tbl].extend(self.fetch(command, commit=True))
        self._commit()
        return rows
870682
def query(self, query, *parameters, **kwargs):
        """"""
        cursor = self._cursor()
        try:
            self._execute(cursor, query, parameters or None, kwargs)
            if cursor.description:
                column_names = [column.name for column in cursor.description]
                res = [Row(zip(column_names, row)) for row in cursor.fetchall()]
                cursor.close()
                return res
        except:
            cursor.close()
            raise
33325
def load_from_dict(db, data, metadata):
    
    # The ORM overhead is too high for this kind of bulk load,
    # so drop down to SQLAlchemy Core.
    # This tries to do minimize the number of SQL commands by loading entire
    # tables at once

    if metadata['version'] != 2:
        raise ValueError('Can only load version 2')

    try:
        bind = db.get_bind(tables.Event)
    except (ValueError, AttributeError):
        pass
    else:
        if bind.dialect.name == 'sqlite':
            db.execute('PRAGMA foreign_keys = ON')

    with bulk_inserter(db) as insert:

        # Load speakers

        speaker_slugs = set()

        for series_slug, series in data['series'].items():
            for event_slug, event in series['events'].items():
                for talk in event.get('talks'):
                    for speaker in talk.get('speakers', ()):
                        if speaker not in speaker_slugs:
                            speaker_slugs.add(speaker)
                            insert(tables.Speaker, {
                                'slug': speaker,
                                'name': speaker,
                            })

        venue_ids = {}

        # Load cities, and their venues

        for city_slug, city in data['cities'].items():
            city_data = city['city']
            insert(tables.City, {
                'slug': city_slug,
                'name': city_data['name'],
                'latitude': city_data['location']['latitude'],
                'longitude': city_data['location']['longitude'],
                '_source': city_data['_source'],
            })

            for venue_slug, venue in city.get('venues', {}).items():
                venue_ids[city_slug, venue_slug] = insert(tables.Venue, {
                    'city_slug': city_slug,
                    'slug': venue_slug,
                    'name': venue['name'],
                    'address': venue.get('address'),
                    'latitude': venue['location']['latitude'],
                    'longitude': venue['location']['longitude'],
                    'notes': venue.get('notes'),
                })


        # Load series, their events, and everything underneath

        for series_slug, series_dir in data['series'].items():

            series = series_dir['series']
            recurrence = series.get('recurrence')
            if recurrence:
                rrule_str = recurrence['rrule']
                rrule.rrulestr(rrule_str)  # check rrule syntax
                recurrence_attrs = {
                    'recurrence_rule': rrule_str,
                    'recurrence_scheme': recurrence['scheme'],
                    'recurrence_description_cs': recurrence['description']['cs'],
                    'recurrence_description_en': recurrence['description']['en'],
                }
            else:
                recurrence_attrs = {
                    'recurrence_rule': None,
                    'recurrence_scheme': None,
                    'recurrence_description_cs': None,
                    'recurrence_description_en': None,
                }
            insert(tables.Series, {
                'slug': series_slug,
                'name': series['name'],
                'home_city_slug': series.get('city'),
                'description_cs': series['description']['cs'],
                'description_en': series['description']['en'],
                'organizer_info': json.dumps(series.get('organizer-info', ())),
                **recurrence_attrs,
            })

            for event_slug, event in series_dir['events'].items():
                venue_slug = event.get('venue')
                city_slug = event['city']
                if venue_slug:
                    venue_id = venue_ids[city_slug, venue_slug]
                else:
                    venue_id = None

                start = make_full_datetime(event['start'])
                end = event.get('end')
                if end is None:
                    end = start.replace(hour=23, minute=59, second=59)
                event_id = insert(tables.Event, {
                    'name': event['name'],
                    'number': event.get('number'),
                    'topic': event.get('topic'),
                    'description': event.get('description'),
                    'date': start.date(),
                    'start_time': start.time(),
                    'end': end,
                    'all_day': event.get('all_day', False),
                    'series_slug': series_slug,
                    'city_slug': city_slug,
                    'venue_id': venue_id,
                    '_source': event['_source']
                })

                for i, talk in enumerate(event.get('talks', ())):
                    talk_id = insert(tables.Talk, {
                        'event_id': event_id,
                        'index': i,
                        'title': talk['title'],
                        'description': talk.get('description'),
                        'is_lightning': talk.get('lightning', False),
                    })

                    for i, speaker in enumerate(talk.get('speakers', ())):
                        assert speaker in speaker_slugs
                        insert(tables.TalkSpeaker, {
                            'talk_id': talk_id,
                            'index': i,
                            'speaker_slug': speaker,
                        })

                    for i, link in enumerate([
                            *({'talk': u} for u in talk.get('urls', ())),
                            *talk.get('coverage', {})]):
                        for kind, url in link.items():
                            insert(tables.TalkLink, {
                                'talk_id': talk_id,
                                'index': i,
                                'url': url,
                                'kind': kind,
                            })

                for i, url in enumerate(event.get('urls', ())):
                    insert(tables.EventLink, {
                        'event_id': event_id,
                        'index': i,
                        'url': url,
                    })
527178
def bulk_query(self, query, *multiparams):
        """"""

        self._conn.execute(text(query), *multiparams)