Example of running a query with timestamp query parameters.
5286
public void runQueryWithTimestampParameters() throws InterruptedException {
    // [START bigquery_query_params_timestamps]
    // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
    ZonedDateTime timestamp = LocalDateTime.of(2016, 12, 7, 8, 0, 0).atZone(ZoneOffset.UTC);
    String query = "SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR);";
    // Note: Standard SQL is required to use query parameters.
    QueryJobConfiguration queryConfig =
        QueryJobConfiguration.newBuilder(query)
            .addNamedParameter(
                "ts_value",
                QueryParameterValue.timestamp(
                    // Timestamp takes microseconds since 1970-01-01T00:00:00 UTC
                    timestamp.toInstant().toEpochMilli() * 1000))
            .build();

    // Print the results.
    DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC);
    for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
      System.out.printf(
          "%s\n",
          formatter.format(
              Instant.ofEpochMilli(
                      // Timestamp values are returned in microseconds since 1970-01-01T00:00:00
                      // UTC,
                      // but org.joda.time.DateTime constructor accepts times in milliseconds.
                      row.get(0).getTimestampValue() / 1000)
                  .atOffset(ZoneOffset.UTC)));
      System.out.printf("\n");
    }
    // [END bigquery_query_params_timestamps]
  }
1212932
public static Sql getPreperSQL(String query, Map<String, Object> parameters) {
		SqlBuilder builder = new SqlBuilder();
		return builder.getPreperSQLWithParameters(query, parameters);
	}
216499
@Override
    public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
    {
        checkParameterBounds(parameterIndex);
        this.parameters[parameterIndex-1] = x == null ? VoltType.NULL_TIMESTAMP : x;
    }
869093
def timeOneSearch(queryString):
    
    startTime = time.clock()
    resultString = backend.runSearchVariants(queryString)
    endTime = time.clock()
    elapsedTime = endTime - startTime
    return resultString, elapsedTime
367010
public static java.sql.Timestamp toTimestamp(String dateTime) {
		java.util.Date newDate = toDate(dateTime);

		if (newDate != null)
			return new java.sql.Timestamp(newDate.getTime());
		else
			return null;
	}
872446
def query_timeseries(self, query, from_time=None, to_time=None, by_post=False):
    
    return timeseries.query_timeseries(self, query, from_time, to_time, by_post=by_post)
1308301
function run(query, params) {
        let stmt = sql.prepare(query);
        params = normalizeParams(params);
        stmt.run(params);
        stmt.free();
    }
1278554
private InputStream runSparqlQuery(String query) throws IOException {
		try {
			String queryString = "query=" + URLEncoder.encode(query, "UTF-8")
					+ "&format=json";
			URL url = new URL("https://query.wikidata.org/sparql?"
					+ queryString);
			HttpURLConnection connection = (HttpURLConnection) url
					.openConnection();
			connection.setRequestMethod("GET");

			return connection.getInputStream();
		} catch (UnsupportedEncodingException | MalformedURLException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
	}
454786
def raw_query(self, query, query_parameters=None):
        
        self.assert_no_raw_query()

        if len(self._where_tokens) != 0 or len(self._select_tokens) != 0 or len(
                self._order_by_tokens) != 0 or len(self._group_by_tokens) != 0:
            raise InvalidOperationException(
                "You can only use raw_query on a new query, without applying any operations "
                "(such as where, select, order_by, group_by, etc)")

        if query_parameters:
            self.query_parameters = query_parameters
        self._query = query
        return self
570610
def query(self, query, param=None):
        

        with self.conn.cursor() as curs:
            print 'XXX QUERY', curs.mogrify(query, param)
            try:
                curs.execute(query, param)
            except BaseException as exc:
                msg = 'query: {}, param: {}, exc: {}'.format(query, param, exc)

                if hasattr(exc, 'pgcode'):
                    msg = '{}, exc code: {}'.format(msg, exc.pgcode)

                print msg
                handle_exc(exc)

            result = curs.fetchall()

        return result
190484
def query_dated(num=10, kind='1'):
        '''
        
        '''
        return TabWiki.select().where(
            TabWiki.kind == kind
        ).order_by(
            TabWiki.time_update.desc()
        ).limit(num)
304876
public static java.sql.Timestamp toSqlTimestamp(java.util.Date date) {
		return new java.sql.Timestamp(date.getTime());
	}
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
968461
function pg_query(query, params) {
	return function(db) {
		var start_time = new Date();
		return do_query(db, query, params).then(function() {

			var end_time = new Date();

			db._record_sample({
				'event': 'query',
				'start': start_time,
				'end': end_time,
				'query': query,
				'params': params
			});

			return db;
		});
	};
}
858171
def run_object_query(client, base_object_query, start_record, limit_to,
                     verbose=False):
    """"""
    if verbose:
        print("[start: %d limit: %d]" % (start_record, limit_to))
    start = datetime.datetime.now()
    result = client.execute_object_query(
        object_query=base_object_query,
        start_record=start_record,
        limit_to=limit_to)
    end = datetime.datetime.now()
    if verbose:
        print("[%s - %s]" % (start, end))
    return result
1172363
@Override
    public void setTime(int parameterIndex, Time x) throws SQLException {
        internalStmt.setTime(parameterIndex, x);
    }
1174927
def queries(self, last_updated_ms):
        """"""
        stats_logger.incr('queries')
        if not g.user.get_id():
            return json_error_response(
                'Please login to access the queries.', status=403)

        # Unix time, milliseconds.
        last_updated_ms_int = int(float(last_updated_ms)) if last_updated_ms else 0

        # UTC date time, same that is stored in the DB.
        last_updated_dt = utils.EPOCH + timedelta(seconds=last_updated_ms_int / 1000)

        sql_queries = (
            db.session.query(Query)
            .filter(
                Query.user_id == g.user.get_id(),
                Query.changed_on >= last_updated_dt,
            )
            .all()
        )
        dict_queries = {q.client_id: q.to_dict() for q in sql_queries}

        now = int(round(time.time() * 1000))

        unfinished_states = [
            QueryStatus.PENDING,
            QueryStatus.RUNNING,
        ]

        queries_to_timeout = [
            client_id for client_id, query_dict in dict_queries.items()
            if (
                query_dict['state'] in unfinished_states and (
                    now - query_dict['startDttm'] >
                    config.get('SQLLAB_ASYNC_TIME_LIMIT_SEC') * 1000
                )
            )
        ]

        if queries_to_timeout:
            update(Query).where(
                and_(
                    Query.user_id == g.user.get_id(),
                    Query.client_id in queries_to_timeout,
                ),
            ).values(state=QueryStatus.TIMED_OUT)

            for client_id in queries_to_timeout:
                dict_queries[client_id]['status'] = QueryStatus.TIMED_OUT

        return json_success(
            json.dumps(dict_queries, default=utils.json_int_dttm_ser))