PySide6.QtSql.QSqlError¶
- class QSqlError¶
The
QSqlErrorclass provides SQL database error information. More…Synopsis¶
Methods¶
def
__init__()def
databaseText()def
driverText()def
isValid()def
__ne__()def
__eq__()def
swap()def
text()def
type()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
A
QSqlErrorobject can provide database-specific error data, including thedriverText()anddatabaseText()messages (or both concatenated together astext()), and thenativeErrorCode()andtype().See also
- class ErrorType¶
This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.
Constant
Description
QSqlError.ErrorType.NoError
No error occurred.
QSqlError.ErrorType.ConnectionError
Connection error.
QSqlError.ErrorType.StatementError
SQL statement syntax error.
QSqlError.ErrorType.TransactionError
Transaction failed error.
QSqlError.ErrorType.UnknownError
Unknown error.
Creates a copy of
other.- __init__([driverText=""[, databaseText=""[, type=QSqlError.ErrorType.NoError[, errorCode=""]]]])
- Parameters:
driverText – str
databaseText – str
type –
ErrorTypeerrorCode – str
Constructs an error containing the driver error text
driverText, the database-specific error textdatabaseText, the typetypeand the error codecode.- databaseText()¶
- Return type:
str
Returns the text of the error as reported by the database. This may contain database-specific descriptions; it may be empty.
See also
- driverText()¶
- Return type:
str
Returns the text of the error as reported by the driver. This may contain database-specific descriptions. It may also be empty.
See also
- isValid()¶
- Return type:
bool
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Returns
trueif an error is set, otherwise false.Example:
model = QSqlQueryModel() model.setQuery("select * from myTable") if model.lastError().isValid(): print(model.lastError())
See also
- nativeErrorCode()¶
- Return type:
str
Returns the database-specific error code, or an empty string if it cannot be determined.
Note
Some drivers (like DB2 or ODBC) may return more than one error code. When this happens,
;is used as separator between the error codes.Compare the
othererror’stype()andnativeErrorCode()to this error and returnstrueif it is not equal.Compare the
othererror’stype()andnativeErrorCode()to this error and returnstrue, if it equal.Swaps this error with
other. This operation is very fast and never fails.- text()¶
- Return type:
str
This is a convenience function that returns
databaseText()anddriverText()concatenated into a single string.See also
Returns the error type, or -1 if the type cannot be determined.