@@ -72,6 +72,13 @@ impl Connection for PostgresDialect {
72
72
log:: info!( "show columns: {}" , & sql) ;
73
73
self . query ( & sql, 0 , 0 ) . await
74
74
}
75
+
76
+ async fn query_count ( & self , sql : & str ) -> anyhow:: Result < usize > {
77
+ let conn = self . get_conn ( & self . database ( ) ) . await ?;
78
+ let row = conn. query_one ( sql, & [ ] ) . await ?;
79
+ let total: u32 = row. get ( 0 ) ;
80
+ Ok ( total as usize )
81
+ }
75
82
}
76
83
77
84
impl PostgresDialect {
@@ -109,15 +116,15 @@ impl PostgresDialect {
109
116
pub async fn get_tables ( & self , db : & str ) -> anyhow:: Result < Vec < Table > > {
110
117
let client = self . get_conn ( db) . await ?;
111
118
112
- let sql = r# "
113
- select
114
- table_catalog as db_name,
115
- table_schema as table_schema,
116
- table_name as table_name,
117
- table_type as table_type,
118
- CASE WHEN table_type='BASE TABLE' THEN 'table' ELSE 'view' END as type
119
- from information_schema.tables WHERE table_schema='public'
120
- "# ;
119
+ let sql = "
120
+ select
121
+ table_catalog as db_name,
122
+ table_schema as table_schema,
123
+ table_name as table_name,
124
+ table_type as table_type,
125
+ CASE WHEN table_type='BASE TABLE' THEN 'table' ELSE 'view' END as type
126
+ from information_schema.tables WHERE table_schema='public'
127
+ " ;
121
128
let mut tables = vec ! [ ] ;
122
129
for row in client. query ( sql, & [ ] ) . await ? {
123
130
tables. push ( Table {
0 commit comments