Expand description
Database executors and connection management for Nautilus ORM.
This crate provides the execution layer for Nautilus, enabling SQL queries
to be run against real databases. It defines the Executor trait and provides
concrete implementations for supported databases.
§Architecture
Executortrait: Abstract interface for query executionRow: Database result representation with hybrid access (positional + named)PgExecutor: PostgreSQL implementation using sqlxMysqlExecutor: MySQL implementation using sqlxSqliteExecutor: SQLite implementation using sqlx
§Example
ⓘ
use nautilus_connector::{execute_all, Executor, PgExecutor, ConnectorResult};
use nautilus_dialect::{Dialect, PostgresDialect};
use nautilus_core::select::SelectBuilder;
#[tokio::main]
async fn main() -> ConnectorResult<()> {
// Create executor
let executor = PgExecutor::new("postgres://localhost/mydb").await?;
let dialect = PostgresDialect;
// Build query
let select = SelectBuilder::new("users")
.columns(vec!["id", "name"])
.build()?;
// Render and execute
let sql = dialect.render_select(&select)?;
let rows = execute_all(&executor, &sql).await?;
// Access results
for row in rows {
let id = row.get("id");
let name = row.get("name");
println!("User: {:?}, {:?}", id, name);
}
Ok(())
}Re-exports§
pub use error::ConnectorError;pub use error::Result as ConnectorResult;pub use error::SqlxErrorKind;pub use transaction::IsolationLevel;pub use transaction::TransactionExecutor;pub use transaction::TransactionOptions;
Modules§
- error
- Error types for the Nautilus connector layer.
- transaction
- Transaction executor for Nautilus.
Structs§
- Client
- A Client holding both a Dialect (for SQL rendering) and an Executor (for query execution).
- Column
- Typed column reference.
- Connector
Pool Options - Optional overrides for the sqlx connection pool and statement cache used by Nautilus executors.
- Mysql
Executor - MySQL executor using sqlx.
- PgExecutor
- PostgreSQL executor using sqlx.
- Row
- A database row with hybrid access patterns.
- RowStream
- A type-erased async stream of
Rowvalues. - Sqlite
Executor - SQLite executor using sqlx.
Enums§
- Value
Hint - Schema-aware coercion hint for a single projected column.
Traits§
- Executor
- Trait for executing SQL queries against a database.
- FromRow
- Trait for decoding database rows into Rust types.
- From
Value - Trait for converting database values to Rust types.
- RowAccess
- Trait for abstracting row data access with lifetime support.
Functions§
- decode_
row_ with_ hints - Normalize a row with hints and decode it via
FromRow. - execute_
all - Execute a SQL query and materialize all rows into a Vec.
- execute_
one - Execute a SQL query and require exactly one row.
- execute_
optional - Execute a SQL query and accept zero or one row.
- normalize_
row_ with_ hints - Normalize a single row using per-column schema hints.
- normalize_
rows_ with_ hints - Normalize a vector of rows using per-column schema hints.
- normalize_
value_ with_ hint - Normalize a single projected value using its schema-aware hint.
Type Aliases§
- Mysql
RowStream - Stream type for MySQL query results.
- PgRow
Stream - Stream type for PostgreSQL query results.
- Sqlite
RowStream - Stream type for SQLite query results.