1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2025 Stoolap Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Top-level Database API
//!
//! This module provides the high-level database interface for Stoolap.
//!
//! # Quick Start
//!
//! ```ignore
//! use stoolap::{Database, params};
//!
//! // Open an in-memory database
//! let db = Database::open_in_memory()?;
//!
//! // Create a table
//! db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)", ())?;
//!
//! // Insert data with parameters
//! db.execute("INSERT INTO users VALUES ($1, $2, $3)", (1, "Alice", 30))?;
//! db.execute("INSERT INTO users VALUES ($1, $2, $3)", params![2, "Bob", 25])?;
//!
//! // Query data
//! for row in db.query("SELECT * FROM users WHERE age > $1", (20,))? {
//! let row = row?;
//! let id: i64 = row.get(0)?;
//! let name: String = row.get("name")?;
//! println!("{}: {}", id, name);
//! }
//!
//! // Query single value
//! let count: i64 = db.query_one("SELECT COUNT(*) FROM users", ())?;
//!
//! // Transactions
//! let mut tx = db.begin()?;
//! tx.execute("UPDATE users SET age = age + 1", ())?;
//! tx.commit()?;
//! ```
//!
//! # Parameter Binding
//!
//! Parameters can be passed in several ways:
//!
//! ```ignore
//! // Empty tuple for no parameters
//! db.execute("CREATE TABLE foo (id INTEGER)", ())?;
//!
//! // Tuple syntax for inline parameters
//! db.execute("INSERT INTO foo VALUES ($1, $2)", (1, "Alice"))?;
//!
//! // params! macro for explicit parameter list
//! db.execute("INSERT INTO foo VALUES ($1, $2)", params![1, "Alice"])?;
//!
//! // Optional values
//! let name: Option<&str> = Some("Alice");
//! db.execute("INSERT INTO foo VALUES ($1, $2)", (1, name))?;
//! ```
//!
//! # Prepared Statements
//!
//! ```ignore
//! let stmt = db.prepare("SELECT * FROM users WHERE id = $1")?;
//!
//! // Execute multiple times with different parameters
//! for id in 1..=10 {
//! for row in stmt.query((id,))? {
//! // ...
//! }
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use Statement;
pub use Transaction;