一键导入
sqlite-sqlx-patterns
Use when writing sqlx queries, working with SQLite WAL mode, storing or loading embedding blobs, or modifying the database schema.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when writing sqlx queries, working with SQLite WAL mode, storing or loading embedding blobs, or modifying the database schema.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when selecting a Gemini model, checking rate limits or quotas, configuring the gemini-rust crate, or debugging model name mismatches.
Create new Kiro skills (Agent Skills). Use when asked to create a skill, write a SKILL.md, add a new workflow to .kiro/skills/, or package agent instructions as a reusable skill.
Use when creating a release, bumping the version, tagging a commit, or working with the GitHub Actions release workflow for rs-summarizer.
Use when editing or creating Askama HTML templates, adding template variables, fixing compile-time template errors, or working with HTMX attributes in templates.
Use when working with tokio::spawn background tasks, the summarization pipeline, task state transitions, or the mark_error/mark_summary_done pattern.
Use when building, running, linting with clippy, formatting with rustfmt, or running cargo commands for the rs-summarizer project.
| name | sqlite-sqlx-patterns |
| description | Use when writing sqlx queries, working with SQLite WAL mode, storing or loading embedding blobs, or modifying the database schema. |
rs-summarizer uses SQLite with WAL (Write-Ahead Logging) mode via the sqlx crate for async database access. This enables concurrent reads during writes — critical for HTMX polling while background tasks update summaries.
use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions};
let options = SqliteConnectOptions::from_str("sqlite:data/summaries.db")?
.create_if_missing(true)
.journal_mode(SqliteJournalMode::Wal);
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect_with(options)
.await?;
sqlx::migrate!("./migrations").run(&pool).await?;
Single migration file at migrations/001_initial.sql:
PRAGMA journal_mode=WAL; at the topsummaries table schema (26 columns)idx_dedup_lookup on (original_source_link, model, summary_timestamp_start)sqlx::query("UPDATE summaries SET summary = summary || ? WHERE identifier = ?")
.bind(chunk)
.bind(identifier)
.execute(db)
.await?;
let row = sqlx::query_as::<_, Summary>("SELECT * FROM summaries WHERE identifier = ?")
.bind(identifier)
.fetch_optional(db)
.await?;
let id = sqlx::query_scalar::<_, i64>(
"SELECT identifier FROM summaries WHERE original_source_link = ? AND model = ? LIMIT 1"
)
.bind(url)
.bind(model)
.fetch_optional(db)
.await?;
| Function | Purpose |
|---|---|
init_db() | Create pool, run migrations |
insert_new_summary() | Insert row, return last_insert_rowid() |
fetch_summary() | Get full row by identifier |
update_transcript() | Set transcript field |
update_summary_chunk() | Append chunk: summary = summary || ? |
mark_summary_done() | Set summary_done=1, tokens, cost, timestamp |
mark_timestamps_done() | Set timestamps_done=1, YouTube format text |
store_embedding() | Store embedding blob + model name |
fetch_all_embeddings() | Get all (id, blob) pairs for similarity search |
fetch_browse_page() | Paginated query: ORDER BY id DESC LIMIT 20 OFFSET ? |
let db_pool = db::init_db("sqlite::memory:").await?;
Embeddings are stored as raw f32 byte blobs (little-endian):
embedding.iter().flat_map(|f| f.to_le_bytes()).collect::<Vec<u8>>()bytes.chunks_exact(4).map(|c| f32::from_le_bytes([c[0],c[1],c[2],c[3]])).collect()blob.len() == dimensions * 4src/db.rs — All database operationsmigrations/001_initial.sql — Schema definitionsrc/models.rs — Summary struct with sqlx::FromRow