API reference - Class QSqlDatabase

Notation used in Ruby API documentation

Description: Binding of QSqlDatabase

Public constructors

new QSqlDatabasenewConstructor QSqlDatabase::QSqlDatabase()
new QSqlDatabasenew(const QSqlDatabase other)Constructor QSqlDatabase::QSqlDatabase(const QSqlDatabase &other)

Public methods

void_assign(const QSqlDatabase other)Assigns another object to self
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
QSqlDatabaseassign(const QSqlDatabase other)Method QSqlDatabase &QSqlDatabase::operator=(const QSqlDatabase &other)
voidcloseMethod void QSqlDatabase::close()
boolcommitMethod bool QSqlDatabase::commit()
[const]stringconnectOptionsMethod QString QSqlDatabase::connectOptions()
voidconnectOptions=(string options = QString())Method void QSqlDatabase::setConnectOptions(const QString &options)
[const]stringconnectionNameMethod QString QSqlDatabase::connectionName()
[const]stringdatabaseNameMethod QString QSqlDatabase::databaseName()
voiddatabaseName=(string name)Method void QSqlDatabase::setDatabaseName(const QString &name)
[const]QSqlDriver ptrdriverMethod QSqlDriver *QSqlDatabase::driver()
[const]stringdriverNameMethod QString QSqlDatabase::driverName()
[const]new QSqlDatabase ptrdupCreates a copy of self
[const]QSqlQueryexec(string query = QString())Method QSqlQuery QSqlDatabase::exec(const QString &query)
[const]stringhostNameMethod QString QSqlDatabase::hostName()
voidhostName=(string host)Method void QSqlDatabase::setHostName(const QString &host)
[const]boolisOpen?Method bool QSqlDatabase::isOpen()
[const]boolisOpenError?Method bool QSqlDatabase::isOpenError()
[const]boolisValid?Method bool QSqlDatabase::isValid()
[const]QSqlErrorlastErrorMethod QSqlError QSqlDatabase::lastError()
[const]QSql_NumericalPrecisionPolicynumericalPrecisionPolicyMethod QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy()
voidnumericalPrecisionPolicy=(const QSql_NumericalPrecisionPolicy precisionPolicy)Method void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
boolopenMethod bool QSqlDatabase::open()
boolopen(string user,
string password)
Method bool QSqlDatabase::open(const QString &user, const QString &password)
[const]stringpasswordMethod QString QSqlDatabase::password()
voidpassword=(string password)Method void QSqlDatabase::setPassword(const QString &password)
[const]intportMethod int QSqlDatabase::port()
voidport=(int p)Method void QSqlDatabase::setPort(int p)
[const]QSqlIndexprimaryIndex(string tablename)Method QSqlIndex QSqlDatabase::primaryIndex(const QString &tablename)
[const]QSqlRecordrecord(string tablename)Method QSqlRecord QSqlDatabase::record(const QString &tablename)
boolrollbackMethod bool QSqlDatabase::rollback()
voidsetConnectOptions(string options = QString())Method void QSqlDatabase::setConnectOptions(const QString &options)
voidsetDatabaseName(string name)Method void QSqlDatabase::setDatabaseName(const QString &name)
voidsetHostName(string host)Method void QSqlDatabase::setHostName(const QString &host)
voidsetNumericalPrecisionPolicy(const QSql_NumericalPrecisionPolicy precisionPolicy)Method void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
voidsetPassword(string password)Method void QSqlDatabase::setPassword(const QString &password)
voidsetPort(int p)Method void QSqlDatabase::setPort(int p)
voidsetUserName(string name)Method void QSqlDatabase::setUserName(const QString &name)
[const]string[]tables(const QSql_TableType type = QSql::Tables)Method QStringList QSqlDatabase::tables(QSql::TableType type)
booltransactionMethod bool QSqlDatabase::transaction()
[const]stringuserNameMethod QString QSqlDatabase::userName()
voiduserName=(string name)Method void QSqlDatabase::setUserName(const QString &name)

Public static methods and constants

QSqlDatabaseaddDatabase(string type,
string connectionName = QLatin1String(QSqlDatabase::defaultConnection))
Static method QSqlDatabase QSqlDatabase::addDatabase(const QString &type, const QString &connectionName)
QSqlDatabaseaddDatabase(QSqlDriver ptr driver,
string connectionName = QLatin1String(QSqlDatabase::defaultConnection))
Static method QSqlDatabase QSqlDatabase::addDatabase(QSqlDriver *driver, const QString &connectionName)
QSqlDatabasecloneDatabase(const QSqlDatabase other,
string connectionName)
Static method QSqlDatabase QSqlDatabase::cloneDatabase(const QSqlDatabase &other, const QString &connectionName)
string[]connectionNamesStatic method QStringList QSqlDatabase::connectionNames()
boolcontains(string connectionName = QLatin1String(QSqlDatabase::defaultConnection))Static method bool QSqlDatabase::contains(const QString &connectionName)
QSqlDatabasedatabase(string connectionName = QLatin1String(QSqlDatabase::defaultConnection),
bool open = true)
Static method QSqlDatabase QSqlDatabase::database(const QString &connectionName, bool open)
string[]driversStatic method QStringList QSqlDatabase::drivers()
boolisDriverAvailable?(string name)Static method bool QSqlDatabase::isDriverAvailable(const QString &name)
voidregisterSqlDriver(string name,
QSqlDriverCreatorBase ptr creator)
Static method void QSqlDatabase::registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator)
voidremoveDatabase(string connectionName)Static method void QSqlDatabase::removeDatabase(const QString &connectionName)

Deprecated methods (protected, public, static, non-static and constructors)

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead

Detailed description

void _assign(const QSqlDatabase other)

Description: Assigns another object to self

void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

[const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

[static] QSqlDatabase addDatabase(string type,string connectionName = QLatin1String(QSqlDatabase::defaultConnection))

Description: Static method QSqlDatabase QSqlDatabase::addDatabase(const QString &type, const QString &connectionName)

This method is static and can be called without an instance.

[static] QSqlDatabase addDatabase(QSqlDriver ptr driver,string connectionName = QLatin1String(QSqlDatabase::defaultConnection))

Description: Static method QSqlDatabase QSqlDatabase::addDatabase(QSqlDriver *driver, const QString &connectionName)

This method is static and can be called without an instance.

QSqlDatabase assign(const QSqlDatabase other)

Description: Method QSqlDatabase &QSqlDatabase::operator=(const QSqlDatabase &other)

[static] QSqlDatabase cloneDatabase(const QSqlDatabase other,string connectionName)

Description: Static method QSqlDatabase QSqlDatabase::cloneDatabase(const QSqlDatabase &other, const QString &connectionName)

This method is static and can be called without an instance.

void close

Description: Method void QSqlDatabase::close()

bool commit

Description: Method bool QSqlDatabase::commit()

[const] string connectOptions

Description: Method QString QSqlDatabase::connectOptions()

Python specific notes:

The object exposes a readable attribute 'connectOptions'. This is the getter.

void connectOptions=(string options = QString())

Description: Method void QSqlDatabase::setConnectOptions(const QString &options)

Python specific notes:

The object exposes a writable attribute 'connectOptions'. This is the setter.

[const] string connectionName

Description: Method QString QSqlDatabase::connectionName()

[static] string[] connectionNames

Description: Static method QStringList QSqlDatabase::connectionNames()

This method is static and can be called without an instance.

[static] bool contains(string connectionName = QLatin1String(QSqlDatabase::defaultConnection))

Description: Static method bool QSqlDatabase::contains(const QString &connectionName)

This method is static and can be called without an instance.

void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

[static] QSqlDatabase database(string connectionName = QLatin1String(QSqlDatabase::defaultConnection),bool open = true)

Description: Static method QSqlDatabase QSqlDatabase::database(const QString &connectionName, bool open)

This method is static and can be called without an instance.

[const] string databaseName

Description: Method QString QSqlDatabase::databaseName()

Python specific notes:

The object exposes a readable attribute 'databaseName'. This is the getter.

void databaseName=(string name)

Description: Method void QSqlDatabase::setDatabaseName(const QString &name)

Python specific notes:

The object exposes a writable attribute 'databaseName'. This is the setter.

void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

Use of this method is deprecated. Use _destroyed? instead

[const] QSqlDriver ptr driver

Description: Method QSqlDriver *QSqlDatabase::driver()

[const] string driverName

Description: Method QString QSqlDatabase::driverName()

[static] string[] drivers

Description: Static method QStringList QSqlDatabase::drivers()

This method is static and can be called without an instance.

[const] new QSqlDatabase ptr dup

Description: Creates a copy of self

[const] QSqlQuery exec(string query = QString())

Description: Method QSqlQuery QSqlDatabase::exec(const QString &query)

Python specific notes:

This method is available as method 'exec_' in Python

[const] string hostName

Description: Method QString QSqlDatabase::hostName()

Python specific notes:

The object exposes a readable attribute 'hostName'. This is the getter.

void hostName=(string host)

Description: Method void QSqlDatabase::setHostName(const QString &host)

Python specific notes:

The object exposes a writable attribute 'hostName'. This is the setter.

[static] bool isDriverAvailable?(string name)

Description: Static method bool QSqlDatabase::isDriverAvailable(const QString &name)

This method is static and can be called without an instance.

[const] bool isOpen?

Description: Method bool QSqlDatabase::isOpen()

[const] bool isOpenError?

Description: Method bool QSqlDatabase::isOpenError()

[const] bool isValid?

Description: Method bool QSqlDatabase::isValid()

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

Use of this method is deprecated. Use _is_const_object? instead

[const] QSqlError lastError

Description: Method QSqlError QSqlDatabase::lastError()

[static] new QSqlDatabase new

Description: Constructor QSqlDatabase::QSqlDatabase()

This method creates an object of class QSqlDatabase.

Python specific notes:

This method is the default initializer of the object

[static] new QSqlDatabase new(const QSqlDatabase other)

Description: Constructor QSqlDatabase::QSqlDatabase(const QSqlDatabase &other)

This method creates an object of class QSqlDatabase.

Python specific notes:

This method is the default initializer of the object

[const] QSql_NumericalPrecisionPolicy numericalPrecisionPolicy

Description: Method QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy()

Python specific notes:

The object exposes a readable attribute 'numericalPrecisionPolicy'. This is the getter.

void numericalPrecisionPolicy=(const QSql_NumericalPrecisionPolicy precisionPolicy)

Description: Method void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)

Python specific notes:

The object exposes a writable attribute 'numericalPrecisionPolicy'. This is the setter.

bool open

Description: Method bool QSqlDatabase::open()

bool open(string user,string password)

Description: Method bool QSqlDatabase::open(const QString &user, const QString &password)

[const] string password

Description: Method QString QSqlDatabase::password()

Python specific notes:

The object exposes a readable attribute 'password'. This is the getter.

void password=(string password)

Description: Method void QSqlDatabase::setPassword(const QString &password)

Python specific notes:

The object exposes a writable attribute 'password'. This is the setter.

[const] int port

Description: Method int QSqlDatabase::port()

Python specific notes:

The object exposes a readable attribute 'port'. This is the getter.

void port=(int p)

Description: Method void QSqlDatabase::setPort(int p)

Python specific notes:

The object exposes a writable attribute 'port'. This is the setter.

[const] QSqlIndex primaryIndex(string tablename)

Description: Method QSqlIndex QSqlDatabase::primaryIndex(const QString &tablename)

[const] QSqlRecord record(string tablename)

Description: Method QSqlRecord QSqlDatabase::record(const QString &tablename)

[static] void registerSqlDriver(string name,QSqlDriverCreatorBase ptr creator)

Description: Static method void QSqlDatabase::registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator)

This method is static and can be called without an instance.

[static] void removeDatabase(string connectionName)

Description: Static method void QSqlDatabase::removeDatabase(const QString &connectionName)

This method is static and can be called without an instance.

bool rollback

Description: Method bool QSqlDatabase::rollback()

void setConnectOptions(string options = QString())

Description: Method void QSqlDatabase::setConnectOptions(const QString &options)

Python specific notes:

The object exposes a writable attribute 'connectOptions'. This is the setter.

void setDatabaseName(string name)

Description: Method void QSqlDatabase::setDatabaseName(const QString &name)

Python specific notes:

The object exposes a writable attribute 'databaseName'. This is the setter.

void setHostName(string host)

Description: Method void QSqlDatabase::setHostName(const QString &host)

Python specific notes:

The object exposes a writable attribute 'hostName'. This is the setter.

void setNumericalPrecisionPolicy(const QSql_NumericalPrecisionPolicy precisionPolicy)

Description: Method void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)

Python specific notes:

The object exposes a writable attribute 'numericalPrecisionPolicy'. This is the setter.

void setPassword(string password)

Description: Method void QSqlDatabase::setPassword(const QString &password)

Python specific notes:

The object exposes a writable attribute 'password'. This is the setter.

void setPort(int p)

Description: Method void QSqlDatabase::setPort(int p)

Python specific notes:

The object exposes a writable attribute 'port'. This is the setter.

void setUserName(string name)

Description: Method void QSqlDatabase::setUserName(const QString &name)

Python specific notes:

The object exposes a writable attribute 'userName'. This is the setter.

[const] string[] tables(const QSql_TableType type = QSql::Tables)

Description: Method QStringList QSqlDatabase::tables(QSql::TableType type)

bool transaction

Description: Method bool QSqlDatabase::transaction()

[const] string userName

Description: Method QString QSqlDatabase::userName()

Python specific notes:

The object exposes a readable attribute 'userName'. This is the getter.

void userName=(string name)

Description: Method void QSqlDatabase::setUserName(const QString &name)

Python specific notes:

The object exposes a writable attribute 'userName'. This is the setter.