56 #if !defined Q_WS_WIN32 102 void init(
const char **cnames,
int numCols);
123 currentMachine(0), skippedStatus(false), skipRow(false),
utf8(false)
167 for (
int i = 0; i < numCols; ++i) {
168 const char* lastDot = strrchr(cnames[i],
'.');
169 const char* fieldName = lastDot ? lastDot + 1 : cnames[i];
175 fieldStr = fieldStr.
mid(1);
206 while ((res = sqlite_step(
currentMachine, &colNum, &fvals, &cnames)) == SQLITE_BUSY) {
208 #if defined Q_WS_WIN32 225 init(cnames, colNum);
228 if (idx < 0 && !initialFetch)
230 for (i = 0; i < colNum; ++i)
236 init(cnames, colNum);
291 int res = sqlite_compile(
d->
access,
297 if (res != SQLITE_OK || err) {
333 return sqlite_changes(
d->
access);
435 int res = sqlite_exec(
d->
access,
"BEGIN", 0,
this, &err);
437 if (res == SQLITE_OK)
452 int res = sqlite_exec(
d->
access,
"COMMIT", 0,
this, &err);
454 if (res == SQLITE_OK)
469 int res = sqlite_exec(
d->
access,
"ROLLBACK", 0,
this, &err);
471 if (res == SQLITE_OK)
489 q.
exec(
QLatin1String(
"SELECT name FROM sqlite_master WHERE type='table' OR type='view'"));
490 else if (type & QSql::Tables)
492 else if (type & QSql::Views)
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.
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
QVariant data(int i)
Returns the data for field index in the current row as a QVariant.
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
const QSqlDriver * driver() const
Returns the driver associated with the result.
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...
static const uint initial_cache_size
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
virtual void setOpen(bool o)
This function sets the open state of the database to open.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
QString escapeIdentifier(const QString &identifier, IdentifierType) const
Returns the identifier escaped according to the database rules.
DriverFeature
This enum contains a list of features a driver might support.
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.
friend class QSQLite2ResultPrivate
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.
QString & replace(int i, int len, QChar after)
QSQLite2Result(const QSQLite2Driver *db)
void chop(int n)
Removes n characters from the end of the string.
QSqlRecord record() const
Returns a QSqlRecord containing the field information for the current query.
int length() const
Returns the number of characters in this string.
QString & prepend(QChar c)
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
QVector< QVariant > firstRow
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
struct sqlite_vm sqlite_vm
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.
void virtual_hook(int id, void *data)
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
bool isActive() const
Returns true if the query is active.
The QObject class is the base class of all Qt objects.
bool commitTransaction()
This function is called to commit a transaction.
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...
sqlite_vm * currentMachine
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool fetchNext(QSqlCachedResult::ValueCache &values, int idx, bool initialFetch)
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QSqlResult * createResult() const
Creates an empty SQL result on the database.
The QStringList class provides a list of strings.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
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.
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
QSQLite2ResultPrivate * d
QVariant::Type type() const
Returns the field's type as stored in the database.
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
QSqlField field(int i) const
Returns the field at position index.
void setForwardOnly(bool forward)
Sets forward only mode to forward.
QSQLite2ResultPrivate(QSQLite2Result *res)
const char * constData() const
Returns a pointer to the data stored in the byte array.
bool gotoNext(QSqlCachedResult::ValueCache &row, int idx)
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 numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
static QVariant::Type nameToType(const QString &typeName)
QSQLite2Driver(QObject *parent=0)
QSqlIndex primaryIndex(const QString &table) const
Returns the primary index for table tableName.
QString & append(QChar c)
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
friend class QSQLite2Result
QObject * parent() const
Returns a pointer to the parent object.
void init(const char **cnames, int numCols)
bool beginTransaction()
This function is called to begin a transaction.
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
bool contains(const QString &name) const
Returns true if there is a field in the record called name; otherwise returns false.
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.
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.
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
bool isValid() const
Returns true if the result is positioned on a valid record (that is, the result is not positioned bef...
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user's loca...
int qstrcmp(const QByteArray &str1, const char *str2)
The QSqlField class manipulates the fields in SQL database tables and views.
QSQLite2DriverPrivate * d
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...
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QVariant value(int i) const
Returns the value of field index in the current record.
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)
IdentifierType
This enum contains a list of SQL identifier types.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool rollbackTransaction()
This function is called to rollback a transaction.