diff --git a/Cargo.lock b/Cargo.lock index 076ac4c..e7e6678 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1006,7 +1006,7 @@ dependencies = [ [[package]] name = "psqlpy" -version = "0.10.1" +version = "0.11.1" dependencies = [ "byteorder", "bytes", diff --git a/Cargo.toml b/Cargo.toml index e6dc160..d4c171a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "psqlpy" -version = "0.10.1" +version = "0.11.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 1272db9..57f7509 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![PyPI - Python Version](https://img.shields.io/badge/PYTHON-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue?style=for-the-badge )](https://pypi.org/project/psqlpy/) +[![PyPI - Python Version](https://img.shields.io/badge/Tested%20On%20PostgreSQL-14%20%7C%2015%20%7C%2016%20%7C17-2be28a?style=for-the-badge +)](https://pypi.org/project/psqlpy/) [![PyPI](https://img.shields.io/pypi/v/psqlpy?style=for-the-badge)](https://pypi.org/project/psqlpy/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/psqlpy?style=for-the-badge)](https://pypistats.org/packages/psqlpy) diff --git a/src/driver/common.rs b/src/driver/common.rs index d2f6aec..dc92a28 100644 --- a/src/driver/common.rs +++ b/src/driver/common.rs @@ -194,7 +194,7 @@ macro_rules! impl_transaction_methods { pub async fn commit(&mut self) -> PSQLPyResult<()> { let conn = self.conn.clone(); let Some(conn) = conn else { - return Err(RustPSQLDriverError::TransactionClosedError("1".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let mut write_conn_g = conn.write().await; write_conn_g.commit().await?; @@ -209,7 +209,7 @@ macro_rules! impl_transaction_methods { pub async fn rollback(&mut self) -> PSQLPyResult<()> { let conn = self.conn.clone(); let Some(conn) = conn else { - return Err(RustPSQLDriverError::TransactionClosedError("2".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let mut write_conn_g = conn.write().await; write_conn_g.rollback().await?; diff --git a/src/driver/cursor.rs b/src/driver/cursor.rs index 248bd08..3a8abe5 100644 --- a/src/driver/cursor.rs +++ b/src/driver/cursor.rs @@ -54,10 +54,10 @@ impl Cursor { async fn query_portal(&self, size: i32) -> PSQLPyResult { let Some(transaction) = &self.transaction else { - return Err(RustPSQLDriverError::TransactionClosedError("3".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let Some(portal) = &self.inner else { - return Err(RustPSQLDriverError::TransactionClosedError("4".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; transaction.query_portal(&portal, size).await } @@ -162,10 +162,10 @@ impl Cursor { let py_future = Python::with_gil(move |gil| { rustdriver_future(gil, async move { let Some(txid) = &txid else { - return Err(RustPSQLDriverError::TransactionClosedError("5".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let Some(portal) = &portal else { - return Err(RustPSQLDriverError::TransactionClosedError("6".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let result = txid.query_portal(&portal, size).await?; diff --git a/src/driver/prepared_statement.rs b/src/driver/prepared_statement.rs index 1880449..03b6c27 100644 --- a/src/driver/prepared_statement.rs +++ b/src/driver/prepared_statement.rs @@ -39,7 +39,7 @@ impl PreparedStatement { impl PreparedStatement { async fn execute(&self) -> PSQLPyResult { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("12".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; diff --git a/src/driver/transaction.rs b/src/driver/transaction.rs index 81845d4..87f1a28 100644 --- a/src/driver/transaction.rs +++ b/src/driver/transaction.rs @@ -71,7 +71,7 @@ impl Transaction { }); let Some(conn) = conn else { - return Err(RustPSQLDriverError::TransactionClosedError("7".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let mut write_conn_g = conn.write().await; write_conn_g @@ -98,7 +98,7 @@ impl Transaction { }); let Some(conn) = conn else { - return Err(RustPSQLDriverError::TransactionClosedError("8".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let mut write_conn_g = conn.write().await; if is_exception_none { @@ -121,7 +121,7 @@ impl Transaction { pub async fn begin(&mut self) -> PSQLPyResult<()> { let conn = &self.conn; let Some(conn) = conn else { - return Err(RustPSQLDriverError::TransactionClosedError("9".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let mut write_conn_g = conn.write().await; write_conn_g @@ -139,7 +139,7 @@ impl Transaction { prepared: Option, ) -> PSQLPyResult { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("10".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -154,7 +154,7 @@ impl Transaction { prepared: Option, ) -> PSQLPyResult { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("11".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -169,7 +169,7 @@ impl Transaction { prepared: Option, ) -> PSQLPyResult> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("12".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -180,7 +180,7 @@ impl Transaction { pub async fn execute_batch(&self, querystring: String) -> PSQLPyResult<()> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("13".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -195,7 +195,7 @@ impl Transaction { prepared: Option, ) -> PSQLPyResult<()> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("14".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -212,7 +212,7 @@ impl Transaction { prepared: Option, ) -> PSQLPyResult { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("15".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -223,7 +223,7 @@ impl Transaction { pub async fn create_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("16".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -236,7 +236,7 @@ impl Transaction { pub async fn release_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("17".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -249,7 +249,7 @@ impl Transaction { pub async fn rollback_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> { let Some(conn) = &self.conn else { - return Err(RustPSQLDriverError::TransactionClosedError("18".into())); + return Err(RustPSQLDriverError::TransactionClosedError); }; let read_conn_g = conn.read().await; @@ -305,6 +305,6 @@ impl Transaction { return future::try_join_all(futures).await; } - Err(RustPSQLDriverError::TransactionClosedError("19".into())) + Err(RustPSQLDriverError::TransactionClosedError) } } diff --git a/src/exceptions/rust_errors.rs b/src/exceptions/rust_errors.rs index 9062a37..f133321 100644 --- a/src/exceptions/rust_errors.rs +++ b/src/exceptions/rust_errors.rs @@ -49,8 +49,8 @@ pub enum RustPSQLDriverError { TransactionSavepointError(String), #[error("Transaction execute error: {0}")] TransactionExecuteError(String), - #[error("Underlying connection is returned to the pool: {0}")] - TransactionClosedError(String), + #[error("Underlying connection is returned to the pool")] + TransactionClosedError, // Cursor Errors #[error("Cursor error: {0}")] @@ -162,7 +162,7 @@ impl From for pyo3::PyErr { RustPSQLDriverError::TransactionExecuteError(_) => { TransactionExecuteError::new_err((error_desc,)) } - RustPSQLDriverError::TransactionClosedError(_) => { + RustPSQLDriverError::TransactionClosedError => { TransactionClosedError::new_err((error_desc,)) } RustPSQLDriverError::BaseCursorError(_) => BaseCursorError::new_err((error_desc,)),