@@ -3,15 +3,15 @@ use std::{env, str::FromStr};
3
3
use sqlx:: {
4
4
migrate:: Migrator ,
5
5
sqlite:: { SqliteConnectOptions , SqlitePool , SqlitePoolOptions } ,
6
- Acquire , ConnectOptions , Executor ,
6
+ Acquire , ConnectOptions , Error , Executor , Pool , Sqlite ,
7
7
} ;
8
8
use tracing:: info;
9
9
10
10
use crate :: util;
11
11
12
12
// kv存储方案:
13
13
pub struct AppSqlStorage {
14
- pub db : SqlitePool ,
14
+ pub conn : SqlitePool ,
15
15
}
16
16
17
17
impl AppSqlStorage {
@@ -29,15 +29,15 @@ impl AppSqlStorage {
29
29
. connect ( )
30
30
. await ;
31
31
32
- let db = SqlitePoolOptions :: new ( ) . min_connections ( 2 ) . connect ( & url) . await ;
32
+ let conn = SqlitePoolOptions :: new ( ) . min_connections ( 2 ) . connect ( & url) . await ;
33
33
34
- match db {
35
- Ok ( db ) => {
36
- info ! ( "connect to sqlite db success" ) ;
37
- Self { db }
34
+ match conn {
35
+ Ok ( conn ) => {
36
+ info ! ( "sqlite conn: {:?}" , conn ) ;
37
+ Self { conn }
38
38
} ,
39
39
Err ( e) => {
40
- panic ! ( "db create error : {:?}" , e) ;
40
+ panic ! ( "sqlite conn err : {:?}" , e) ;
41
41
} ,
42
42
}
43
43
}
@@ -62,7 +62,7 @@ impl AppSqlStorage {
62
62
match db {
63
63
Ok ( db) => {
64
64
info ! ( "connect to sqlite db success" ) ;
65
- Self { db }
65
+ Self { conn : db }
66
66
} ,
67
67
Err ( e) => {
68
68
panic ! ( "db create error: {:?}" , e) ;
@@ -76,7 +76,7 @@ impl AppSqlStorage {
76
76
. await
77
77
. expect ( "migrations failed" ) ;
78
78
79
- match m. run ( & self . db ) . await {
79
+ match m. run ( & self . conn ) . await {
80
80
Ok ( _) => {
81
81
println ! ( "migrations run success" ) ;
82
82
} ,
0 commit comments