内容表

上一话题

QSqlDriverCreatorBase

下一话题

QSqlField

QSqlError

QSqlError class provides SQL database error information. 更多

Inheritance diagram of PySide2.QtSql.QSqlError

概要

函数

详细描述

A QSqlError object can provide database-specific error data, including the driverText() and databaseText() messages (or both concatenated together as text() ), and the nativeErrorCode() and type() .

class 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()
											

另请参阅

type()

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

另请参阅

number()

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

另请参阅

type()

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.

PySide2.QtSql.QSqlError. type ( )
返回类型

ErrorType

Returns the error type, or -1 if the type cannot be determined.

另请参阅

setType()