The `crate` library is the official Python client for CrateDB, a distributed SQL database. It provides a DB-API 2.0 compliant interface for connecting to CrateDB clusters, executing SQL queries, and managing data. The current version is 2.1.2, and it typically sees regular updates aligned with CrateDB releases and Python ecosystem changes.
pip install crateVerified import paths — ran on the pinned version, not inferred.
Connects to a CrateDB instance, creates a table, inserts two rows, and then queries them. Requires a running CrateDB instance (default: localhost:4200).
Install `crate-sqlalchemy` (`pip install crate-sqlalchemy`) and import the dialect from `crate_sqlalchemy.dialect`.
Ensure the connection string starts with `http://` or `https://`, e.g., `http://localhost:4200`.
Convert `datetime` objects to Unix milliseconds (integer) or ISO 8601 strings before passing them in parameters, e.g., `int(dt_object.timestamp() * 1000)`.
Ensure CrateDB is running and listening on the correct address (default: `localhost:4200`). Verify firewall rules and the `CRATEDB_HOST` environment variable or hardcoded connection string.
Before inserting, convert the `datetime` object to an integer representing milliseconds since epoch, or an ISO 8601 string. Example: `cursor.execute("INSERT INTO my_table (ts_col) VALUES (?) ", (int(my_datetime.timestamp() * 1000),))`.Install the dedicated SQLAlchemy package: `pip install crate-sqlalchemy`. Then, import the dialect from `crate_sqlalchemy.dialect`.