def
__eq__
(other)
def
__ne__
(other)
def
databaseText
()
def
driverText
()
def
isValid
()
def
nativeErrorCode
()
def
number
()
def
setDatabaseText
(databaseText)
def
setDriverText
(driverText)
def
setNumber
(number)
def
setType
(type)
def
swap
(other)
def
text
()
def
type
()
A
QSqlErrorobject can provide database-specific error data, including thedriverText()anddatabaseText()messages (or both concatenated together astext()), and thenativeErrorCode()andtype().另请参阅
QSqlError
(
other
)
¶
QSqlError([driverText=””[, databaseText=””[, type=NoError[, errorCode=””]]]])
QSqlError(driverText, databaseText, type, number)
注意
This constructor is deprecated.
type
–
ErrorType
driverText – unicode
databaseText – unicode
other
–
QSqlError
number
–
int
errorCode – unicode
PySide2.QtSql.QSqlError.
ErrorType
¶
This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.
|
常量 |
描述 |
|---|---|
|
QSqlError.NoError |
没有发生错误。 |
|
QSqlError.ConnectionError |
Connection error. |
|
QSqlError.StatementError |
SQL statement syntax error. |
|
QSqlError.TransactionError |
Transaction failed error. |
|
QSqlError.UnknownError |
Unknown error. |
PySide2.QtSql.QSqlError.
databaseText
(
)
¶
unicode
Returns the text of the error as reported by the database. This may contain database-specific descriptions; it may be empty.
PySide2.QtSql.QSqlError.
driverText
(
)
¶
unicode
Returns the text of the error as reported by the driver. This may contain database-specific descriptions. It may also be empty.
PySide2.QtSql.QSqlError.
isValid
(
)
¶
bool
返回
true
if an error is set, otherwise false.
范例:
model = QSqlQueryModel()
model.setQuery("select * from myTable")
if model.lastError().isValid():
print model.lastError()
另请参阅
PySide2.QtSql.QSqlError.
nativeErrorCode
(
)
¶
unicode
Returns the database-specific error code, or an empty string if it cannot be determined.
PySide2.QtSql.QSqlError.
number
(
)
¶
int
注意
此函数被弃用。
Returns the database-specific error number, or -1 if it cannot be determined.
Returns 0 if the error code is not an integer.
警告
Some databases use alphanumeric error codes, which makes unreliable if such a database is used.
使用
nativeErrorCode()
instead
PySide2.QtSql.QSqlError.
__ne__
(
other
)
¶
other
–
QSqlError
bool
Compare the
other
error’s values to this error and returns
true
if it is not equal.
PySide2.QtSql.QSqlError.
__eq__
(
other
)
¶
other
–
QSqlError
bool
Compare the
other
error’s values to this error and returns
true
, if it equal.
PySide2.QtSql.QSqlError.
setDatabaseText
(
databaseText
)
¶
databaseText – unicode
注意
此函数被弃用。
Sets the database error text to the value of
databaseText
.
使用
QSqlError
(const
QString
&
driverText
, const
QString
&
databaseText
,
ErrorType
type, int number) instead
PySide2.QtSql.QSqlError.
setDriverText
(
driverText
)
¶
driverText – unicode
注意
此函数被弃用。
Sets the driver error text to the value of
driverText
.
使用
QSqlError
(const
QString
&
driverText
, const
QString
&
databaseText
,
ErrorType
type, int number) instead
PySide2.QtSql.QSqlError.
setNumber
(
number
)
¶
number
–
int
注意
此函数被弃用。
Sets the database-specific error number to
number
.
使用
QSqlError
(const
QString
&
driverText
, const
QString
&
databaseText
,
ErrorType
type, int number) instead
另请参阅
PySide2.QtSql.QSqlError.
setType
(
type
)
¶
type
–
ErrorType
注意
此函数被弃用。
Sets the error type to the value of
type
.
使用
QSqlError
(const
QString
&
driverText
, const
QString
&
databaseText
,
ErrorType
type, int number) instead
另请参阅
PySide2.QtSql.QSqlError.
swap
(
other
)
¶
other
–
QSqlError
Swaps error
other
with this error. This operation is very fast and never fails.
PySide2.QtSql.QSqlError.
text
(
)
¶
unicode
This is a convenience function that returns
databaseText()
and
driverText()
concatenated into a single string.