stale-kilobyte-24744
12/31/2022, 5:39 PMrust
let con = pool.acquire().await?; // pool is the PgPool Shuttle injects.
// event is a struct that for now only contains one property: title
let event_id = sqlx::query_as!(
sqlx::types::Uuid,
"INSERT INTO events (title) VALUES(?) RETURNING id",
event.title
)
.fetch_one(con)
.await?;
I get following error during compilation:
> DATABASE_URL must be set to use query macros
The question is where do I get that variable and where do I set it in a shuttle app?enough-exabyte-92081
12/31/2022, 7:36 PMcargo sqlx prepare
commit the new file generated and you can proceed with the buildagreeable-painting-48846
12/31/2022, 8:26 PMPgPool::connect("foobar").await (where PgPool is sqlx::PgPool) or whatever and then pass that variable in when you need a db connectionstale-kilobyte-24744
12/31/2022, 11:16 PMstale-kilobyte-24744
12/31/2022, 11:17 PM