- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Friends

# QSqlDatabase Class Reference

Search for all occurrences

## Detailed Description

Definition at line 78 of file qsqldatabase.h.

`#include <qsqldatabase.h>`

List of all members.

## Public Member Functions
| QSqlDatabase ()
| QSqlDatabase (const QSqlDatabase &other)
| ~QSqlDatabase ()
QSqlDatabase & | operator= (const QSqlDatabase &other)
bool | open ()
bool | open (const QString &user, const QString &password)
void | close ()
bool | isOpen () const
bool | isOpenError () const
QStringList | tables (QSql::TableType type=QSql::Tables) const
QSqlIndex | primaryIndex (const QString &tablename) const
QSqlRecord | record (const QString &tablename) const
QSqlQuery | exec (const QString &query=QString()) const
QSqlError | lastError () const
bool | isValid () const
bool | transaction ()
bool | commit ()
bool | rollback ()
void | setDatabaseName (const QString &name)
void | setUserName (const QString &name)
void | setPassword (const QString &password)
void | setHostName (const QString &host)
void | setPort (int p)
void | setConnectOptions (const QString &options=QString())
QString | databaseName () const
QString | userName () const
QString | password () const
QString | hostName () const
QString | driverName () const
int | port () const
QString | connectOptions () const
QString | connectionName () const
void | setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy precisionPolicy)
QSql::NumericalPrecisionPolicy | numericalPrecisionPolicy () const
QSqlDriver * | driver () const
## Static Public Member Functions
static QSqlDatabase | addDatabase (const QString &type, const QString &connectionName=QLatin1String(defaultConnection))
static QSqlDatabase | addDatabase (QSqlDriver *driver, const QString &connectionName=QLatin1String(defaultConnection))
static QSqlDatabase | cloneDatabase (const QSqlDatabase &other, const QString &connectionName)
static QSqlDatabase | database (const QString &connectionName=QLatin1String(defaultConnection), bool open=true)
static void | removeDatabase (const QString &connectionName)
static bool | contains (const QString &connectionName=QLatin1String(defaultConnection))
static QStringList | drivers ()
static QStringList | connectionNames ()
static void | registerSqlDriver (const QString &name, QSqlDriverCreatorBase *creator)
static bool | isDriverAvailable (const QString &name)
## Public Attributes
QT_STATIC_CONST char * | defaultConnection
## Protected Member Functions
| QSqlDatabase (const QString &type)
| QSqlDatabase (QSqlDriver *driver)
## Friends
class | QSqlDatabasePrivate

## Constructor & Destructor Documentation

QSqlDatabase | ( |  | ) |

QSqlDatabase | ( | const QSqlDatabase & | other | ) |

~QSqlDatabase | ( |  | ) |

QSqlDatabase | ( | const QString & | type | ) | `[explicit, protected]`

QSqlDatabase | ( | QSqlDriver * | driver | ) | `[explicit, protected]`

## Member Function Documentation

QSqlDatabase& operator= | ( | const QSqlDatabase & | other | ) |

bool open | ( |  | ) |

Search for all occurrences

bool open | ( | const QString & | user,
|  | const QString & | password
| ) |  |

Search for all occurrences

void close | ( |  | ) |

Search for all occurrences

bool isOpen | ( |  | ) | const

Search for all occurrences

bool isOpenError | ( |  | ) | const

Search for all occurrences

QStringList tables | ( | QSql::TableType | type = `QSql::Tables` | ) | const

Search for all occurrences

QSqlIndex primaryIndex | ( | const QString & | tablename | ) | const

Search for all occurrences

QSqlRecord record | ( | const QString & | tablename | ) | const

Search for all occurrences

QSqlQuery exec | ( | const QString & | query = `QString()` | ) | const

Search for all occurrences

QSqlError lastError | ( |  | ) | const

Search for all occurrences

bool isValid | ( |  | ) | const

Search for all occurrences

bool transaction | ( |  | ) |

Search for all occurrences

bool commit | ( |  | ) |

Search for all occurrences

bool rollback | ( |  | ) |

Search for all occurrences

void setDatabaseName | ( | const QString & | name | ) |

Search for all occurrences

void setUserName | ( | const QString & | name | ) |

Search for all occurrences

void setPassword | ( | const QString & | password | ) |

Search for all occurrences

void setHostName | ( | const QString & | host | ) |

Search for all occurrences

void setPort | ( | int | p | ) |

Search for all occurrences

void setConnectOptions | ( | const QString & | options = `QString()` | ) |

Search for all occurrences

QString databaseName | ( |  | ) | const

Search for all occurrences

QString userName | ( |  | ) | const

Search for all occurrences

QString password | ( |  | ) | const

Search for all occurrences

QString hostName | ( |  | ) | const

Search for all occurrences

QString driverName | ( |  | ) | const

Search for all occurrences

int port | ( |  | ) | const

Search for all occurrences

QString connectOptions | ( |  | ) | const

Search for all occurrences

QString connectionName | ( |  | ) | const

Search for all occurrences

void setNumericalPrecisionPolicy | ( | QSql::NumericalPrecisionPolicy | precisionPolicy | ) |

Search for all occurrences

QSql::NumericalPrecisionPolicy numericalPrecisionPolicy | ( |  | ) | const

Search for all occurrences

QSqlDriver* driver | ( |  | ) | const

Search for all occurrences

static QSqlDatabase addDatabase | ( | const QString & | type,
|  | const QString & | connectionName = `QLatin1String(defaultConnection)`
| ) |  | `[static]`

Search for all occurrences

static QSqlDatabase addDatabase | ( | QSqlDriver * | driver,
|  | const QString & | connectionName = `QLatin1String(defaultConnection)`
| ) |  | `[static]`

Search for all occurrences

static QSqlDatabase cloneDatabase | ( | const QSqlDatabase & | other,
|  | const QString & | connectionName
| ) |  | `[static]`

Search for all occurrences

static QSqlDatabase database | ( | const QString & | connectionName = `QLatin1String(defaultConnection)`,
|  | bool | open = `true`
| ) |  | `[static]`

Search for all occurrences

static void removeDatabase | ( | const QString & | connectionName | ) | `[static]`

Search for all occurrences

static bool contains | ( | const QString & | connectionName = `QLatin1String(defaultConnection)` | ) | `[static]`

Search for all occurrences

static QStringList drivers | ( |  | ) | `[static]`

Search for all occurrences

static QStringList connectionNames | ( |  | ) | `[static]`

Search for all occurrences

static void registerSqlDriver | ( | const QString & | name,
|  | QSqlDriverCreatorBase * | creator
| ) |  | `[static]`

Search for all occurrences

static bool isDriverAvailable | ( | const QString & | name | ) | `[static]`

Search for all occurrences

## Friends And Related Function Documentation

friend class QSqlDatabasePrivate `[friend]`

Search for all occurrences

Definition at line 149 of file qsqldatabase.h.

## Member Data Documentation

QT_STATIC_CONST char* defaultConnection

Search for all occurrences

Definition at line 128 of file qsqldatabase.h.

The documentation for this class was generated from the following file:

- QtSql/qsqldatabase.h

QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase
QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase QSqlDatabase