influxdata/influxdb · error · Error::InfluxqlNoDatabase
must specify a 'db' parameter, or provide the database in…
Error message
must specify a 'db' parameter, or provide the database in the InfluxQL query
What it means
The v1 query API needs a target database, taken either from the `db` request parameter or from the query itself (e.g. `ON <db>` clause). When neither is present this error is thrown. It prevents executing a query with no resolvable namespace.
Solutions
- Add the `db` query parameter to the request, e.g. `?db=mydb&q=...`.
- Alternatively include the database in the query: `SELECT * FROM "mydb"."autogen".cpu`.
- Configure the client/datasource default database so `db` is always sent.
Example fix
// before GET /query?q=SELECT+*+FROM+cpu // after GET /query?db=mydb&q=SELECT+*+FROM+cpu
Defensive patterns
Strategy: validation
Validate before calling
function resolveDatabase(params, q) {
const onMatch = /\bON\s+["'`]?([\w-]+)/i.exec(q);
if (!params.db && !onMatch) {
throw new Error("query requires a 'db' parameter or ON <db> clause");
}
return params.db ?? onMatch[1];
} Prevention
- Always send the `db` parameter from a single well-known client config value.
- Centralize query construction so the database is injected in one place.
- Include the database in fully-qualified FROM clauses when omitting `db`.
When it happens
Trigger: GET/POST to the v1 /query endpoint without a `db` parameter and with an InfluxQL statement that does not specify a database (no `ON` clause), e.g. `GET /query?q=SELECT * FROM cpu`.
Common situations: Forgetting the `db` query parameter when migrating 1.x clients; dropping the `ON` clause when converting queries; misconfigured dashboards that omit the datasource default DB.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Database not found
- datafusion error
- must specify a 'db' parameter, or provide the database in…
- provided a database in both the parameters
- Cannot retrieve database
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/a46e5cf585fe103a.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_v1_query_api/src/error.rs:58
/// Serde decode error
#[error("error decoding params from url: {0}")]
SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),
// SerdeJsonError
#[error("error decoding query body: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("datafusion error: {0}")]
Datafusion(#[from] DataFusionError),
#[error("error in InfluxQL statement: {0}")]
InfluxqlRewrite(#[from] rewrite::Error),
#[error("must provide only one InfluxQl statement per query")]
InfluxqlSingleStatement,
#[error("must specify a 'db' parameter, or provide the database in the InfluxQL query")]
InfluxqlNoDatabase,
#[error(
"provided a database in both the parameters ({param_db}) and \
query string ({query_db}) that do not match, if providing a query \
that specifies the database, you can omit the 'database' parameter \
from your request"
)]
InfluxqlDatabaseMismatch { param_db: String, query_db: String },
#[error(
"provided a retention policy in both the parameters ({param_rp}) and \
query string ({query_rp}) that do not match, if providing a query \
that specifies the retention_policy, you can omit the 'rp' parameter \
from your request"
)]
InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },
View on GitHub (pinned to 06200ef96b)