99 QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))),
119 void initColumns(
bool emptyResultset);
134 stmt(0), skippedStatus(false), skipRow(false)
154 sqlite3_finalize(
stmt);
160 int nCols = sqlite3_column_count(
stmt);
166 for (
int i = 0; i < nCols; ++i) {
168 sqlite3_column_name16(
stmt, i))
173 sqlite3_column_decltype16(
stmt, i)));
175 int stp = emptyResultset ? -1 : sqlite3_column_type(
stmt, i);
235 res = sqlite3_step(
stmt);
243 if (idx < 0 && !initialFetch)
246 switch (sqlite3_column_type(
stmt, i)) {
248 values[i + idx] =
QByteArray(static_cast<const char *>(
249 sqlite3_column_blob(
stmt, i)),
250 sqlite3_column_bytes(
stmt, i));
253 values[i + idx] = sqlite3_column_int64(
stmt, i);
258 values[i + idx] = sqlite3_column_int(
stmt, i);
261 values[i + idx] = sqlite3_column_int64(
stmt, i);
266 values[i + idx] = sqlite3_column_double(
stmt, i);
274 values[i + idx] =
QString(reinterpret_cast<const QChar *>(
275 sqlite3_column_text16(
stmt, i)),
276 sqlite3_column_bytes16(
stmt, i) /
sizeof(
QChar));
288 case SQLITE_CONSTRAINT:
292 res = sqlite3_reset(
stmt);
332 sqlite3_reset(
d->
stmt);
355 const void *pzTail = NULL;
357 #if (SQLITE_VERSION_NUMBER >= 3003011) 365 if (res != SQLITE_OK) {
389 int res = sqlite3_reset(
d->
stmt);
390 if (res != SQLITE_OK) {
396 int paramCount = sqlite3_bind_parameter_count(
d->
stmt);
397 if (paramCount == values.
count()) {
398 for (
int i = 0; i < paramCount; ++i) {
403 res = sqlite3_bind_null(
d->
stmt, i + 1);
405 switch (value.
type()) {
409 ba->
size(), SQLITE_STATIC);
412 res = sqlite3_bind_int(
d->
stmt, i + 1, value.
toInt());
424 res = sqlite3_bind_text16(
d->
stmt, i + 1, str->
utf16(),
425 (str->
size()) *
sizeof(
QChar), SQLITE_STATIC);
430 res = sqlite3_bind_text16(
d->
stmt, i + 1, str.
utf16(),
431 (str.
size()) *
sizeof(
QChar), SQLITE_TRANSIENT);
435 if (res != SQLITE_OK) {
470 return sqlite3_changes(
d->
access);
552 bool sharedCache =
false;
553 int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000;
555 foreach(
const QString &option, opts) {
563 openMode = SQLITE_OPEN_READONLY;
568 sqlite3_enable_shared_cache(sharedCache);
571 sqlite3_busy_timeout(
d->
access, timeOut);
589 if (sqlite3_close(
d->
access) != SQLITE_OK)
658 "UNION ALL SELECT name FROM sqlite_temp_master WHERE %1");
661 else if (type & QSql::Tables)
663 else if (type & QSql::Views)
686 if (indexOfSeparator > -1) {
688 table = tableName.
mid(indexOfSeparator + 1);
695 if (onlyPIndex && !isPk)
704 fld.setDefaultValue(q.
value(4));
The QVariant class acts like a union for the most common Qt data types.
The QSqlError class provides SQL database error information.
The QSqlIndex class provides functions to manipulate and describe database indexes.
T qobject_cast(QObject *object)
static QVariant::Type qGetColumnType(const QString &tpName)
QVariant data(int i)
Returns the data for field index in the current row as a QVariant.
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
const QSqlDriver * driver() const
Returns the driver associated with the result.
QVector< QVariant > firstRow
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
virtual void setOpen(bool o)
This function sets the open state of the database to open.
DriverFeature
This enum contains a list of features a driver might support.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
QString & prepend(QChar c)
The QSqlQuery class provides a means of executing and manipulating SQL statements.
static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, int errorCode=-1)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if there are no fields in the record; otherwise returns false.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
The QSqlRecord class encapsulates a database record.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
The QChar class provides a 16-bit Unicode character.
static QString _q_escapeIdentifier(const QString &identifier)
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
void resize(int size)
Sets the size of the vector to size.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
ErrorType
This enum type describes the context in which the error occurred, e.
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
bool fetchNext(QSqlCachedResult::ValueCache &values, int idx, bool initialFetch)
static bool isEmpty(const char *str)
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
int access(const char *, int)
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
int size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
bool commitTransaction()
This function is called to commit a transaction.
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
bool gotoNext(QSqlCachedResult::ValueCache &row, int idx)
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QSQLiteResult(const QSQLiteDriver *db)
QString escapeIdentifier(const QString &identifier, IdentifierType) const
Returns the identifier escaped according to the database rules.
void setForwardOnly(bool forward)
Sets forward only mode to forward.
const T & at(int i) const
Returns the item at index position i in the vector.
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
const char * constData() const
Returns a pointer to the data stored in the byte array.
friend class QSQLiteResultPrivate
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
int count() const
Returns the number of fields in the record.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QSQLiteResultPrivate(QSQLiteResult *res)
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
QSqlError lastError() const
Returns error information about the last error (if any) that occurred with this query.
QString & append(QChar c)
QSqlResult * createResult() const
Creates an empty SQL result on the database.
QString trimmed(QString source)
QString databaseText() const
Returns the text of the error as reported by the database.
void clear()
Clears the contents of the string and makes it empty.
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
QSQLiteDriver(QObject *parent=0)
const void * constData() const
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
bool rollbackTransaction()
This function is called to rollback a transaction.
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
QList< QSQLiteResult * > results
QSqlError lastError() const
Returns the last error associated with the result.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
int size() const
Returns the number of bytes in this byte array.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
void clear()
Removes all the record's fields.
QSqlIndex primaryIndex(const QString &table) const
Returns the primary index for table tableName.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool onlyPIndex=false)
bool isValid() const
Returns true if the result is positioned on a valid record (that is, the result is not positioned bef...
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database...
friend class QSQLiteResult
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
bool exec()
Executes the query, returning true if successful; otherwise returns false.
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
The QSqlField class manipulates the fields in SQL database tables and views.
bool exec(const QString &query)
Executes the SQL in query.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
bool beginTransaction()
This function is called to begin a transaction.
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
void setAutoValue(bool autoVal)
Marks the field as an auto-generated value if autoVal is true.
void virtual_hook(int id, void *data)
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
QVector< QVariant > & boundValues() const
Returns a vector of the result's bound values for the current record (row).
void initColumns(bool emptyResultset)
QVariant value(int i) const
Returns the value of field index in the current record.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void virtual_hook(int id, void *data)
const QChar * constData() const
Returns a pointer to the data stored in the QString.
IdentifierType
This enum contains a list of SQL identifier types.
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
void setSqlType(int type)
The QList class is a template class that provides lists.
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.