Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting in Python bindings #526

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ impl Cursor {

// TODO: use stmt_is_dml to set rowcount
if stmt_is_dml {
todo!()
return Err(PyErr::new::<NotSupportedError, _>(
"DML statements (INSERT/UPDATE/DELETE) are not fully supported in this version",
)
.into());
}

Ok(Cursor {
Expand Down Expand Up @@ -181,18 +184,24 @@ impl Cursor {
}
}

pub fn close(&self) -> Result<()> {
todo!()
pub fn close(&self) -> PyResult<()> {
Err(PyErr::new::<NotSupportedError, _>(
"close() is not supported in this version",
))
}

#[pyo3(signature = (sql, parameters=None))]
pub fn executemany(&self, sql: &str, parameters: Option<Py<PyList>>) {
todo!()
pub fn executemany(&self, sql: &str, parameters: Option<Py<PyList>>) -> PyResult<()> {
Err(PyErr::new::<NotSupportedError, _>(
"executemany() is not supported in this version",
))
}

#[pyo3(signature = (size=None))]
pub fn fetchmany(&self, size: Option<i64>) {
todo!()
pub fn fetchmany(&self, size: Option<i64>) -> PyResult<Option<Vec<PyObject>>> {
Err(PyErr::new::<NotSupportedError, _>(
"fetchmany() is not supported in this version",
))
}
}

Expand Down Expand Up @@ -228,12 +237,16 @@ impl Connection {
drop(self.conn.clone());
}

pub fn commit(&self) {
todo!()
pub fn commit(&self) -> PyResult<()> {
Err(PyErr::new::<NotSupportedError, _>(
"Transactions are not supported in this version",
))
}

pub fn rollback(&self) {
todo!()
pub fn rollback(&self) -> PyResult<()> {
Err(PyErr::new::<NotSupportedError, _>(
"Transactions are not supported in this version",
))
}
}

Expand Down
Loading