QSqlRecord

Inheritance diagram of QSqlRecord

Synopsis

Functions

def __eq__ (other)
def __ne__ (other)
def append (field)
def clear ()
def clearValues ()
def contains (name)
def count ()
def field (i)
def field (name)
def fieldName (i)
def indexOf (name)
def insert (pos,field)
def isEmpty ()
def isGenerated (i)
def isGenerated (name)
def isNull (i)
def isNull (name)
def operator= (other)
def remove (pos)
def replace (pos,field)
def setGenerated (i,generated)
def setGenerated (name,generated)
def setNull (i)
def setNull (name)
def setValue (i,val)
def setValue (name,val)
def value (i)
def value (name)

Detailed Description

The QSqlRecord class encapsulates a database record.

The QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). 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 QSqlRecord.setValue() ; if you want to set a field to null use QSqlRecord.setNull() . To find the position of a field by name use QSqlRecord.indexOf() , and to find the name of a field at a particular position use QSqlRecord.fieldName() . Use QSqlRecord.field() to retrieve a QSqlField object for a given field. Use 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 QSqlRecord.isGenerated() is true are included in the generated SQL.

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

class PySide.QtSql.QSqlRecord
class PySide.QtSql.QSqlRecord(other)
Parameter:other – QSqlRecord

Constructs an empty record.

Constructs a copy of other .

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

QSqlRecord.append(field)
Parameter:field – QSqlField

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

QSqlRecord.clear()

Removes all the record’s fields.

QSqlRecord.clearValues()

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

QSqlRecord.contains(name)
Parameter:name – QString
Return type:bool

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

QSqlRecord.count()
Return type:int

Returns the number of fields in the record.

QSqlRecord.field(i)
Parameter:i – int
Return type:QSqlField

Returns the field at position index . If the position is out of range, an empty field is returned.

QSqlRecord.field(name)
Parameter:name – QString
Return type:QSqlField

This is an overloaded function.

Returns the field called name .

QSqlRecord.fieldName(i)
Parameter:i – int
Return type:QString

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

QSqlRecord.indexOf(name)
Parameter:name – QString
Return type: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.

QSqlRecord.insert(pos, field)
Parameters:
  • pos – int
  • field – QSqlField

Inserts the field field at position pos in the record.

QSqlRecord.isEmpty()
Return type:bool

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

QSqlRecord.isGenerated(name)
Parameter:name – QString
Return type:bool

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

QSqlRecord.isGenerated(i)
Parameter:i – int
Return type: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.

QSqlRecord.isNull(i)
Parameter:i – int
Return type: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.

QSqlRecord.isNull(name)
Parameter:name – QString
Return type:bool

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

QSqlRecord.__ne__(other)
Parameter:other – QSqlRecord
Return type:bool

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

See also

QSqlRecord.operator==()

QSqlRecord.operator=(other)
Parameter:other – QSqlRecord
Return type:QSqlRecord

Sets the record equal to other .

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

QSqlRecord.__eq__(other)
Parameter:other – QSqlRecord
Return type: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

QSqlRecord.operator!=()

QSqlRecord.remove(pos)
Parameter:pos – int

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

QSqlRecord.replace(pos, field)
Parameters:
  • pos – int
  • field – QSqlField

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

QSqlRecord.setGenerated(i, generated)
Parameters:
  • i – int
  • generated – bool

This is an overloaded function.

Sets the generated flag for the field index to generated .

QSqlRecord.setGenerated(name, generated)
Parameters:
  • name – QString
  • generated – 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 QSqlQueryModel for example.

QSqlRecord.setNull(i)
Parameter:i – int

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

QSqlRecord.setNull(name)
Parameter:name – QString

This is an overloaded function.

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

QSqlRecord.setValue(i, val)
Parameters:
  • i – int
  • val – QVariant

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

QSqlRecord.setValue(name, val)
Parameters:
  • name – QString
  • val – QVariant

This is an overloaded function.

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

QSqlRecord.value(name)
Parameter:name – QString
Return type:QVariant

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.

QSqlRecord.value(i)
Parameter:i – int
Return type:QVariant

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