diff --git a/docs/docs/core/initialization.mdx b/docs/docs/core/initialization.mdx index 0c9e54c15..2ea51c648 100644 --- a/docs/docs/core/initialization.mdx +++ b/docs/docs/core/initialization.mdx @@ -49,7 +49,7 @@ This takes care of the following effects: The following environment variables are supported: -* `COCOINDEX_DATABASE_URL` (required): The URI of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex` +* `COCOINDEX_DATABASE_URL` (required): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex` * `COCOINDEX_DATABASE_USER` (optional): The username for the Postgres database. If not provided, username will come from `COCOINDEX_DATABASE_URL`. * `COCOINDEX_DATABASE_PASSWORD` (optional): The password for the Postgres database. If not provided, password will come from `COCOINDEX_DATABASE_URL`. @@ -66,9 +66,9 @@ It takes a `Settings` object as argument, which is a dataclass that contains the #### DatabaseConnectionSpec `DatabaseConnectionSpec` has the following fields: -* `uri` (type: `str`, required): The URI of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`. -* `user` (type: `str`, optional): The username for the Postgres database. If not provided, username will come from `uri`. -* `password` (type: `str`, optional): The password for the Postgres database. If not provided, password will come from `uri`. +* `url` (type: `str`, required): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`. +* `user` (type: `str`, optional): The username for the Postgres database. If not provided, username will come from `url`. +* `password` (type: `str`, optional): The password for the Postgres database. If not provided, password will come from `url`. ### Example @@ -83,7 +83,7 @@ def main(): cocoindex.init( cocoindex.Settings( database=cocoindex.DatabaseConnectionSpec( - uri="postgres://cocoindex:cocoindex@localhost/cocoindex" + url="postgres://cocoindex:cocoindex@localhost/cocoindex" ))) ... diff --git a/docs/docs/ops/storages.md b/docs/docs/ops/storages.md index fa88ba8ac..a6d5ac39b 100644 --- a/docs/docs/ops/storages.md +++ b/docs/docs/ops/storages.md @@ -379,7 +379,7 @@ Please read and agree the license before starting the instance. The `Neo4j` storage exports each row as a relationship to Neo4j Knowledge Graph. The spec takes the following fields: * `connection` (type: [auth reference](../core/flow_def#auth-registry) to `Neo4jConnectionSpec`): The connection to the Neo4j database. `Neo4jConnectionSpec` has the following fields: - * `uri` (type: `str`): The URI of the Neo4j database to use as the internal storage, e.g. `bolt://localhost:7687`. + * `url` (type: `str`): The URI of the Neo4j database to use as the internal storage, e.g. `bolt://localhost:7687`. * `user` (type: `str`): Username for the Neo4j database. * `password` (type: `str`): Password for the Neo4j database. * `db` (type: `str`, optional): The name of the Neo4j database to use as the internal storage, e.g. `neo4j`. diff --git a/python/cocoindex/lib.py b/python/cocoindex/lib.py index 832ccb77d..61bc221be 100644 --- a/python/cocoindex/lib.py +++ b/python/cocoindex/lib.py @@ -24,7 +24,7 @@ def _load_field(target: dict[str, str], name: str, env_name: str, required: bool @dataclass class DatabaseConnectionSpec: - uri: str + url: str user: str | None = None password: str | None = None @@ -38,7 +38,7 @@ def from_env(cls) -> Self: """Load settings from environment variables.""" db_kwargs: dict[str, str] = dict() - _load_field(db_kwargs, "uri", "COCOINDEX_DATABASE_URL", required=True) + _load_field(db_kwargs, "url", "COCOINDEX_DATABASE_URL", required=True) _load_field(db_kwargs, "user", "COCOINDEX_DATABASE_USER") _load_field(db_kwargs, "password", "COCOINDEX_DATABASE_PASSWORD") database = DatabaseConnectionSpec(**db_kwargs) diff --git a/src/lib_context.rs b/src/lib_context.rs index 76a56a6a0..4f3ca4040 100644 --- a/src/lib_context.rs +++ b/src/lib_context.rs @@ -70,13 +70,13 @@ pub struct DbPools { impl DbPools { pub async fn get_pool(&self, conn_spec: &settings::DatabaseConnectionSpec) -> Result { let db_pool_cell = { - let key = (conn_spec.uri.clone(), conn_spec.user.clone()); + let key = (conn_spec.url.clone(), conn_spec.user.clone()); let mut db_pools = self.pools.lock().unwrap(); db_pools.entry(key).or_default().clone() }; let pool = db_pool_cell .get_or_try_init(|| async move { - let mut pg_options: PgConnectOptions = conn_spec.uri.parse()?; + let mut pg_options: PgConnectOptions = conn_spec.url.parse()?; if let Some(user) = &conn_spec.user { pg_options = pg_options.username(user); } diff --git a/src/settings.rs b/src/settings.rs index 33cd90c25..2cbcf1460 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -2,7 +2,7 @@ use serde::Deserialize; #[derive(Deserialize, Debug)] pub struct DatabaseConnectionSpec { - pub uri: String, + pub url: String, pub user: Option, pub password: Option, }