1
1
use bytes:: Buf ;
2
- use deadpool_postgres:: Object ;
2
+ use deadpool_postgres:: { Object , Transaction } ;
3
3
use postgres_types:: { ToSql , Type } ;
4
- use pyo3:: { Py , PyAny , Python } ;
4
+ use pyo3:: { pyclass , Py , PyAny , Python } ;
5
5
use std:: vec;
6
6
use tokio_postgres:: { Client , CopyInSink , Row , Statement , ToStatement } ;
7
7
@@ -18,6 +18,11 @@ pub enum PsqlpyConnection {
18
18
SingleConn ( Client ) ,
19
19
}
20
20
21
+ // #[pyclass]
22
+ // struct Portal {
23
+ // trans: Transaction<'static>,
24
+ // }
25
+
21
26
impl PsqlpyConnection {
22
27
/// Prepare cached statement.
23
28
///
@@ -38,6 +43,25 @@ impl PsqlpyConnection {
38
43
}
39
44
}
40
45
46
+ // pub async fn transaction(&mut self) -> Portal {
47
+ // match self {
48
+ // PsqlpyConnection::PoolConn(pconn, _) => {
49
+ // let b = unsafe {
50
+ // std::mem::transmute::<Transaction<'_>, Transaction<'static>>(pconn.transaction().await.unwrap())
51
+ // };
52
+ // Portal {trans: b}
53
+ // // let c = b.bind("SELECT 1", &[]).await.unwrap();
54
+ // // b.query_portal(&c, 1).await;
55
+ // }
56
+ // PsqlpyConnection::SingleConn(sconn) => {
57
+ // let b = unsafe {
58
+ // std::mem::transmute::<Transaction<'_>, Transaction<'static>>(sconn.transaction().await.unwrap())
59
+ // };
60
+ // Portal {trans: b}
61
+ // },
62
+ // }
63
+ // }
64
+
41
65
/// Delete prepared statement.
42
66
///
43
67
/// # Errors
0 commit comments