https://github.com/svelterust/axum-sqlite
Provides Sqlite database for axum
https://github.com/svelterust/axum-sqlite
axum rust sqlite
Last synced: 7 months ago
JSON representation
Provides Sqlite database for axum
- Host: GitHub
- URL: https://github.com/svelterust/axum-sqlite
- Owner: svelterust
- Created: 2022-04-07T00:21:51.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-15T05:47:02.000Z (over 2 years ago)
- Last Synced: 2025-02-01T16:17:32.967Z (12 months ago)
- Topics: axum, rust, sqlite
- Language: Rust
- Homepage: https://docs.rs/axum-sqlite/latest/axum_sqlite/
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# axum-sqlite
```bash
cargo add axum-sqlite
```
Provides Sqlite database for `axum`.
```rust
use axum::{Extension, response::Html, routing::get, Router};
use std::net::SocketAddr;
use axum_sqlite::*;
#[tokio::main]
async fn main() {
let app = Router::new()
.route("/", get(index))
.layer(Database::new(":memory:").unwrap());
axum::Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
.serve(app.into_make_service())
.await
.unwrap();
}
async fn index(Extension(database): Extension) -> Html<&'static str> {
let connection = database.connection().unwrap(); // Do stuff with connection
Html("Hello, sqlite!")
}
```