An SQLite database into a Actix-Web server using SQLx, enabling persistent storage for the app
Create a SQLite file and run this SQL manually or via migration:
-- posts.sql
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT NOT NULL
);
sqlite3 blog.db < posts.sql
cargo run
curl -X POST -H "Content-Type: application/json" \
-d '{"title":"SQLite Test", "content":"Rust + SQLx is cool"}' \
http://127.0.0.1:8080/posts
curl http://127.0.0.1:8080/posts