mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-03 15:55:45 +00:00
JSON Example
Setup
-
Declare the database URL
export DATABASE_URL="postgres://postgres:password@localhost/json"
-
Create the database.
$ sqlx db create
-
Run sql migrations
$ sqlx migrate run
Usage
Add a person
echo '{ "name": "John Doe", "age": 30 }' | cargo run -- add
or with extra keys
echo '{ "name": "Jane Doe", "age": 25, "array": ["string", true, 0] }' | cargo run -- add
List all people
cargo run