Table Of Contents

Previous topic

QSqlResult

Next topic

QSqlIndex

QSqlRecord

Inherited by: QSqlIndex

Synopsis

Functions

Detailed Description

The PySide.QtSql.QSqlRecord class encapsulates a database record.

The PySide.QtSql.QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). PySide.QtSql.QSqlRecord supports adding and removing fields as well as setting and retrieving field values.

The values of a record’s fields’ can be set by name or position with PySide.QtSql.QSqlRecord.setValue() ; if you want to set a field to null use PySide.QtSql.QSqlRecord.setNull() . To find the position of a field by name use PySide.QtSql.QSqlRecord.indexOf() , and to find the name of a field at a particular position use PySide.QtSql.QSqlRecord.fieldName() . Use PySide.QtSql.QSqlRecord.field() to retrieve a PySide.QtSql.QSqlField object for a given field. Use PySide.QtSql.QSqlRecord.contains() to see if the record contains a particular field name.

When queries are generated to be executed on the database only those fields for which PySide.QtSql.QSqlRecord.isGenerated() is true are included in the generated SQL.

A record can have fields added with PySide.QtSql.QSqlRecord.append() or PySide.QtSql.QSqlRecord.insert() , replaced with PySide.QtSql.QSqlRecord.replace() , and removed with PySide.QtSql.QSqlRecord.remove() . All the fields can be removed with PySide.QtSql.QSqlRecord.clear() . The number of fields is given by PySide.QtSql.QSqlRecord.count() ; all their values can be cleared (to null) using PySide.QtSql.QSqlRecord.clearValues() .

class PySide.QtSql.QSqlRecord
class PySide.QtSql.QSqlRecord(other)
Parameters:otherPySide.QtSql.QSqlRecord

Constructs an empty record.

Constructs a copy of other .

PySide.QtSql.QSqlRecord is implicitly shared . This means you can make copies of a record in constant time .

PySide.QtSql.QSqlRecord.append(field)
Parameters:fieldPySide.QtSql.QSqlField

Append a copy of field field to the end of the record.

PySide.QtSql.QSqlRecord.clear()

Removes all the record’s fields.

PySide.QtSql.QSqlRecord.clearValues()

Clears the value of all fields in the record and sets each field to null.

PySide.QtSql.QSqlRecord.contains(name)
Parameters:name – unicode
Return type:PySide.QtCore.bool

Returns true if there is a field in the record called name ; otherwise returns false.

PySide.QtSql.QSqlRecord.count()
Return type:PySide.QtCore.int

Returns the number of fields in the record.

PySide.QtSql.QSqlRecord.field(i)
Parameters:iPySide.QtCore.int
Return type:PySide.QtSql.QSqlField

Returns the field at position index . If the index is out of range, function returns a default-constructed value .

PySide.QtSql.QSqlRecord.field(name)
Parameters:name – unicode
Return type:PySide.QtSql.QSqlField

This is an overloaded function.

Returns the field called name .

PySide.QtSql.QSqlRecord.fieldName(i)
Parameters:iPySide.QtCore.int
Return type:unicode

Returns the name of the field at position index . If the field does not exist, an empty string is returned.

PySide.QtSql.QSqlRecord.indexOf(name)
Parameters:name – unicode
Return type:PySide.QtCore.int

Returns the position of the field called name within the record, or -1 if it cannot be found. Field names are not case-sensitive. If more than one field matches, the first one is returned.

PySide.QtSql.QSqlRecord.insert(pos, field)
Parameters:

Inserts the field field at position pos in the record.

PySide.QtSql.QSqlRecord.isEmpty()
Return type:PySide.QtCore.bool

Returns true if there are no fields in the record; otherwise returns false.

PySide.QtSql.QSqlRecord.isGenerated(name)
Parameters:name – unicode
Return type:PySide.QtCore.bool

Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false.

PySide.QtSql.QSqlRecord.isGenerated(i)
Parameters:iPySide.QtCore.int
Return type:PySide.QtCore.bool

This is an overloaded function.

Returns true if the record has a field at position index and this field is to be generated (the default); otherwise returns false.

PySide.QtSql.QSqlRecord.isNull(i)
Parameters:iPySide.QtCore.int
Return type:PySide.QtCore.bool

This is an overloaded function.

Returns true if the field index is null or if there is no field at position index ; otherwise returns false.

PySide.QtSql.QSqlRecord.isNull(name)
Parameters:name – unicode
Return type:PySide.QtCore.bool

Returns true if the field called name is null or if there is no field called name ; otherwise returns false.

PySide.QtSql.QSqlRecord.__ne__(other)
Parameters:otherPySide.QtSql.QSqlRecord
Return type:PySide.QtCore.bool

Returns true if this object is not identical to other ; otherwise returns false.

See also

PySide.QtSql.QSqlRecord.operator==()

PySide.QtSql.QSqlRecord.__eq__(other)
Parameters:otherPySide.QtSql.QSqlRecord
Return type:PySide.QtCore.bool

Returns true if this object is identical to other (i.e., has the same fields in the same order); otherwise returns false.

See also

PySide.QtSql.QSqlRecord.operator!=()

PySide.QtSql.QSqlRecord.remove(pos)
Parameters:posPySide.QtCore.int

Removes the field at position pos . If pos is out of range, nothing happens.

PySide.QtSql.QSqlRecord.replace(pos, field)
Parameters:

Replaces the field at position pos with the given field . If pos is out of range, nothing happens.

PySide.QtSql.QSqlRecord.setGenerated(i, generated)
Parameters:
  • iPySide.QtCore.int
  • generatedPySide.QtCore.bool

This is an overloaded function.

Sets the generated flag for the field index to generated .

PySide.QtSql.QSqlRecord.setGenerated(name, generated)
Parameters:
  • name – unicode
  • generatedPySide.QtCore.bool

Sets the generated flag for the field called name to generated . If the field does not exist, nothing happens. Only fields that have generated set to true are included in the SQL that is generated by PySide.QtSql.QSqlQueryModel for example.

PySide.QtSql.QSqlRecord.setNull(i)
Parameters:iPySide.QtCore.int

Sets the value of field index to null. If the field does not exist, nothing happens.

PySide.QtSql.QSqlRecord.setNull(name)
Parameters:name – unicode

This is an overloaded function.

Sets the value of the field called name to null. If the field does not exist, nothing happens.

PySide.QtSql.QSqlRecord.setValue(i, val)
Parameters:
  • iPySide.QtCore.int
  • val – object

Sets the value of the field at position index to val . If the field does not exist, nothing happens.

PySide.QtSql.QSqlRecord.setValue(name, val)
Parameters:
  • name – unicode
  • val – object

This is an overloaded function.

Sets the value of the field called name to val . If the field does not exist, nothing happens.

PySide.QtSql.QSqlRecord.value(name)
Parameters:name – unicode
Return type:object

This is an overloaded function.

Returns the value of the field called name in the record. If field name does not exist an invalid variant is returned.

PySide.QtSql.QSqlRecord.value(i)
Parameters:iPySide.QtCore.int
Return type:object

Returns the value of the field located at position index in the record. If index is out of bounds, an invalid PySide.QtCore.QVariant is returned.