• PySide 模块
  • PySide.QtSql
  • 内容表

    上一话题

    QSqlField

    下一话题

    QSqlRelation

    QSqlError

    概要

    函数

    详细描述

    PySide.QtSql.QSqlError class provides SQL database error information.

    A PySide.QtSql.QSqlError object can provide database-specific error data, including the PySide.QtSql.QSqlError.driverText() and PySide.QtSql.QSqlError.databaseText() messages (or both concatenated together as PySide.QtSql.QSqlError.text() ), and the error PySide.QtSql.QSqlError.number() and PySide.QtSql.QSqlError.type() . The functions all have setters so that you can create and return PySide.QtSql.QSqlError objects from your own classes, for example from your own SQL drivers.

    class PySide.QtSql. QSqlError ( other )
    class PySide.QtSql. QSqlError ( [ driverText="" [ , databaseText="" [ , type=NoError [ , number=-1 ] ] ] ] )
    参数:

    Creates a copy of other .

    Constructs an error containing the driver error text driverText , the database-specific error text databaseText , the type type and the optional error number number .

    PySide.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.
    PySide.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.

    PySide.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.

    PySide.QtSql.QSqlError. isValid ( )
    返回类型: PySide.QtCore.bool

    Returns true if an error is set, otherwise false.

    范例:

    model = QSqlQueryModel()
    model.setQuery("select * from myTable")
    if model.lastError().isValid():
        print model.lastError()
    											
    PySide.QtSql.QSqlError. number ( )
    返回类型: PySide.QtCore.int

    Returns the database-specific error number, or -1 if it cannot be determined.

    PySide.QtSql.QSqlError. setDatabaseText ( databaseText )
    参数: databaseText – unicode

    Sets the database error text to the value of databaseText .

    PySide.QtSql.QSqlError. setDriverText ( driverText )
    参数: driverText – unicode

    Sets the driver error text to the value of driverText .

    PySide.QtSql.QSqlError. setNumber ( number )
    参数: number PySide.QtCore.int

    Sets the database-specific error number to number .

    PySide.QtSql.QSqlError. setType ( type )
    参数: type PySide.QtSql.QSqlError.ErrorType

    Sets the error type to the value of type .

    PySide.QtSql.QSqlError. text ( )
    返回类型: unicode

    This is a convenience function that returns PySide.QtSql.QSqlError.databaseText() and PySide.QtSql.QSqlError.driverText() concatenated into a single string.

    PySide.QtSql.QSqlError. type ( )
    返回类型: PySide.QtSql.QSqlError.ErrorType

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