File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
examples/postgres/preferred-crates Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ async fn main() -> anyhow::Result<()> {
34
34
uses_rust_decimal:: create_table ( & mut conn) . await ?;
35
35
uses_time:: create_table ( & mut conn) . await ?;
36
36
37
- let user_id = sqlx:: query !(
37
+ let user_id = sqlx:: query_scalar !(
38
38
"insert into users(username, password_hash) values($1, $2) returning id" ,
39
39
"user_foo" ,
40
40
"<pretend this is a password hash>" ,
@@ -46,6 +46,8 @@ async fn main() -> anyhow::Result<()> {
46
46
. fetch_one ( & mut conn)
47
47
. await ?;
48
48
49
+ println ! ( "Created user: {user:?}" ) ;
50
+
49
51
let session =
50
52
uses_time:: create_session ( & mut conn, SessionData { user_id } , SESSION_DURATION ) . await ?;
51
53
@@ -62,5 +64,7 @@ async fn main() -> anyhow::Result<()> {
62
64
. await ?
63
65
. expect ( "expected purchase" ) ;
64
66
67
+ println ! ( "Created purchase: {purchase:?}" ) ;
68
+
65
69
Ok ( ( ) )
66
70
}
Original file line number Diff line number Diff line change 1
1
use chrono:: { DateTime , Utc } ;
2
2
use sqlx:: PgExecutor ;
3
3
4
- #[ derive( sqlx:: FromRow ) ]
5
- struct Purchase {
4
+ #[ derive( sqlx:: FromRow , Debug ) ]
5
+ pub struct Purchase {
6
6
pub id : Uuid ,
7
7
pub user_id : Uuid ,
8
8
pub amount : Decimal ,
You can’t perform that action at this time.
0 commit comments