Skip to content

add sqlite serialize/deserialize example#4167

Open
mattrighetti wants to merge 1 commit intolaunchbadge:mainfrom
mattrighetti:example/sqlx-sqlite-serialize
Open

add sqlite serialize/deserialize example#4167
mattrighetti wants to merge 1 commit intolaunchbadge:mainfrom
mattrighetti:example/sqlx-sqlite-serialize

Conversation

@mattrighetti
Copy link
Contributor

@mattrighetti mattrighetti commented Feb 18, 2026

Does your PR solve an issue?

No, it's just an example to show how the serialize and deserialize APIs can be used.

Is this a breaking change?

No.

- Use SqliteOwnedBuf with serialize/deserialize to snapshot
  an in-memory database as raw bytes
- Embed the bytes in a custom container format (magic header + db)
- Round-trip: create → serialize → write → read → deserialize → query
@mattrighetti mattrighetti force-pushed the example/sqlx-sqlite-serialize branch from ccae8ea to 7becb51 Compare March 5, 2026 23:49
@mattrighetti
Copy link
Contributor Author

Just updated the commit message to re-trigger CI

Comment on lines +1 to +7
/// Demonstrates serialize/deserialize by embedding a SQLite database inside a custom
/// binary container format.
///
/// The container prepends a magic header to the raw SQLite bytes, making it impossible
/// to open directly with `SqliteConnectOptions::filename()`. This is the whole point:
/// `sqlite3_serialize` / `sqlite3_deserialize` let you treat a database as an opaque
/// byte slice that can live inside any format you control.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel that this really makes sense to carry as an example, because this is a really niche use-case. These examples are targeted more at beginners and common use-cases to use as a basis. This is more like a demo/proof-of-concept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have anything specific in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants