Kexi API Documentation (2.0 alpha)

KexiDB::SQLiteConnection Class Reference

#include <sqliteconnection.h>

Inheritance diagram for KexiDB::SQLiteConnection:

KexiDB::Connection KexiDB::Object List of all members.

Detailed Description

sqlite-specific connection

Definition at line 37 of file sqliteconnection.h.

Public Member Functions

virtual ~SQLiteConnection ()
virtual CursorprepareQuery (const QString &statement, uint cursor_options=0)
virtual CursorprepareQuery (QuerySchema &query, uint cursor_options=0)
virtual PreparedStatement::Ptr prepareStatement (PreparedStatement::StatementType type, FieldList &fields)
virtual bool isReadOnly () const

Protected Member Functions

 SQLiteConnection (Driver *driver, ConnectionData &conn_data)
virtual bool drv_connect (KexiDB::ServerVersionInfo &version)
virtual bool drv_disconnect ()
virtual bool drv_getDatabasesList (QStringList &list)
virtual bool drv_getTablesList (QStringList &list)
virtual bool drv_containsTable (const QString &tableName)
virtual bool drv_createDatabase (const QString &dbName=QString::null)
virtual bool drv_useDatabase (const QString &dbName=QString::null, bool *cancelled=0, MessageHandler *msgHandler=0)
virtual bool drv_closeDatabase ()
virtual bool drv_dropDatabase (const QString &dbName=QString::null)
virtual bool drv_executeSQL (const QString &statement)
virtual Q_ULLONG drv_lastInsertRowID ()
virtual int serverResult ()
virtual QString serverResultName ()
virtual QString serverErrorMsg ()
virtual void drv_clearServerResult ()
virtual tristate drv_changeFieldProperty (TableSchema &table, Field &field, const QString &propertyName, const QVariant &value)
tristate changeFieldType (TableSchema &table, Field &field, Field::Type type)
 for drv_changeFieldProperty()

Protected Attributes

SQLiteConnectionInternald
 for future extensions

Friends

class SQLiteDriver
class SQLiteCursor


Constructor & Destructor Documentation

SQLiteConnection::~SQLiteConnection  )  [virtual]
 

Definition at line 93 of file sqliteconnection.cpp.

References d, KexiDB::Connection::destroy(), and KexiDBDrvDbg.

SQLiteConnection::SQLiteConnection Driver driver,
ConnectionData conn_data
[protected]
 

Used by driver

Definition at line 87 of file sqliteconnection.cpp.


Member Function Documentation

tristate SQLiteConnection::changeFieldType TableSchema table,
Field field,
Field::Type  type
[protected]
 

for drv_changeFieldProperty()

From http://sqlite.org/datatype3.html : Version 3 enhances provides the ability to store integer and real numbers in a more compact format and the capability to store BLOB data.

Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes: NULL. The value is a NULL value. INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number. TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16-LE). BLOB. The value is a blob of data, stored exactly as it was input.

Column Affinity In SQLite version 3, the type of a value is associated with the value itself, not with the column or variable in which the value is stored. .The type affinity of a column is the recommended type for data stored in that column.

See alter_table_type_conversions.ods for details.

Definition at line 102 of file sqlitealter.cpp.

References affinityForType(), cancelled, and KexiDB::Field::type().

Referenced by drv_changeFieldProperty().

tristate SQLiteConnection::drv_changeFieldProperty TableSchema table,
Field field,
const QString propertyName,
const QVariant &  value
[protected, virtual]
 

Todo:
msg

Reimplemented from KexiDB::Connection.

Definition at line 62 of file sqlitealter.cpp.

References cancelled, changeFieldType(), KexiDB::intToFieldType(), and KexiDB::Field::InvalidType.

void SQLiteConnection::drv_clearServerResult  )  [protected, virtual]
 

Clears number of last server operation's result stored as a single integer. Formally, this integer should be set to value that means "NO ERRORS" or "OK". This method is called by clearError(). For reimplementation. By default does nothing.

See also:
serverErrorMsg()

Reimplemented from KexiDB::Object.

Definition at line 334 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::errmsg_p, KexiDB::SQLiteConnectionInternal::res, and SQLITE_OK.

bool SQLiteConnection::drv_closeDatabase  )  [protected, virtual]
 

For reimplemenation: closes previously opened database using connection.

Implements KexiDB::Connection.

Definition at line 235 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::data, ERR_CLOSE_FAILED, KexiDB::Object::setError(), SQLITE_BUSY, sqlite_close(), and SQLITE_OK.

Referenced by drv_useDatabase().

bool SQLiteConnection::drv_connect KexiDB::ServerVersionInfo version  )  [protected, virtual]
 

For reimplemenation: connects to database. version should be set to real server's version.

Returns:
true on success.

Implements KexiDB::Connection.

Definition at line 103 of file sqliteconnection.cpp.

References KexiDBDrvDbg, KexiDB::ServerVersionInfo::major, KexiDB::ServerVersionInfo::minor, KexiDB::ServerVersionInfo::release, SQLITE_VERSION, and KexiDB::ServerVersionInfo::string.

bool SQLiteConnection::drv_containsTable const QString tableName  )  [protected, virtual]
 

LOW LEVEL METHOD. For reimplemenation: returns true if table with name tableName exists in the database.

Returns:
false if it does not exist or error occurred. The lookup is case insensitive.

Implements KexiDB::Connection.

Definition at line 129 of file sqliteconnection.cpp.

References KexiDB::Connection::driver(), and KexiDB::Connection::resultExists().

bool SQLiteConnection::drv_createDatabase const QString dbName = QString::null  )  [protected, virtual]
 

Creates new database using connection. Note: Do not pass dbName arg because for file-based engine (that has one database per connection) it is defined during connection.

Implements KexiDB::Connection.

Definition at line 157 of file sqliteconnection.cpp.

References d, KexiDB::Connection::data(), KexiDB::SQLiteConnectionInternal::data, drv_useDatabase(), KexiDB::SQLiteConnectionInternal::errmsg_p, sqlite_open(), and KexiDB::SQLiteConnectionInternal::storeResult().

bool SQLiteConnection::drv_disconnect  )  [protected, virtual]
 

For reimplemenation: disconnects database

Returns:
true on success.

Implements KexiDB::Connection.

Definition at line 116 of file sqliteconnection.cpp.

References KexiDBDrvDbg.

bool SQLiteConnection::drv_dropDatabase const QString dbName = QString::null  )  [protected, virtual]
 

Drops database from the server using connection. After drop, database shouldn't be accessible anymore, so database file is just removed. See note from drv_useDatabase().

Implements KexiDB::Connection.

Definition at line 261 of file sqliteconnection.cpp.

References KexiDB::Connection::data(), ERR_ACCESS_RIGHTS, and KexiDB::Object::setError().

bool SQLiteConnection::drv_executeSQL const QString statement  )  [protected, virtual]
 

Executes query statement, but without returning resulting rows (used mostly for functional queries). Only use this method if you really need.

Implements KexiDB::Connection.

Definition at line 285 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::data, KexiDB::SQLiteConnectionInternal::errmsg_p, KexiDB::SQLiteConnectionInternal::res, sqlite_exec(), SQLITE_OK, KexiDB::SQLiteConnectionInternal::storeResult(), and KexiDB::SQLiteConnectionInternal::temp_st.

bool SQLiteConnection::drv_getDatabasesList QStringList &  list  )  [protected, virtual]
 

For reimplemenation: loads list of databases' names available for this connection and adds these names to list. If your server is not able to offer such a list, consider reimplementing drv_databaseExists() instead. The method should return true only if there was no error on getting database names list from the server. Default implementation puts empty list into list and returns true.

Reimplemented from KexiDB::Connection.

Definition at line 122 of file sqliteconnection.cpp.

References KexiDB::Connection::data().

bool SQLiteConnection::drv_getTablesList QStringList &  list  )  [protected, virtual]
 

LOW LEVEL METHOD. For reimplemenation: loads low-level list of table names available for this connection. The names are in lower case. The method should return true only if there was no error on getting database names list from the server.

Implements KexiDB::Connection.

Definition at line 136 of file sqliteconnection.cpp.

References KexiDB::Connection::deleteCursor(), KexiDB::Cursor::eof(), KexiDB::Object::error(), KexiDB::Connection::executeQuery(), KexiDBWarn, KexiDB::Object::m_sql, KexiDB::Cursor::moveFirst(), KexiDB::Cursor::moveNext(), and KexiDB::Cursor::value().

Q_ULLONG SQLiteConnection::drv_lastInsertRowID  )  [protected, virtual]
 

Returns:
unique identifier of last inserted row. Typically this is just primary key value. This identifier could be reused when we want to reference just inserted row. Note for driver developers: contact js (at) iidea.pl if your engine do not offers this information.

Implements KexiDB::Connection.

Definition at line 313 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::data, and sqlite_last_insert_rowid().

bool SQLiteConnection::drv_useDatabase const QString dbName = QString::null,
bool *  cancelled = 0,
MessageHandler msgHandler = 0
[protected, virtual]
 

Opens existing database using connection. Do not pass dbName arg because for file-based engine (that has one database per connection) it is defined during connection. If you pass it, database file name will be changed.

Implements KexiDB::Connection.

Definition at line 169 of file sqliteconnection.cpp.

References KexiDB::Object::askQuestion(), KexiDB::Connection::clearError(), d, KexiDB::Connection::data(), KexiDB::SQLiteConnectionInternal::data, drv_closeDatabase(), ERR_ACCESS_RIGHTS, KexiDB::SQLiteConnectionInternal::errmsg_p, isReadOnly(), KexiDB::Connection::isReadOnly(), KexiDB::SQLiteConnectionInternal::res, KexiDB::Object::setError(), SQLITE_OK, sqlite_open(), and KexiDB::SQLiteConnectionInternal::storeResult().

Referenced by drv_createDatabase().

bool SQLiteConnection::isReadOnly  )  const [virtual]
 

Reimplemented to provide real read-only flag of the connection

Reimplemented from KexiDB::Connection.

Definition at line 359 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::data, and KexiDB::Connection::isReadOnly().

Referenced by drv_useDatabase().

Cursor * SQLiteConnection::prepareQuery QuerySchema query,
uint  cursor_options = 0
[virtual]
 

Implements KexiDB::Connection.

Definition at line 280 of file sqliteconnection.cpp.

References SQLiteCursor.

Cursor * SQLiteConnection::prepareQuery const QString statement,
uint  cursor_options = 0
[virtual]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Statement is build from data provided by table schema, it is like "select * from table_name".

Implements KexiDB::Connection.

Definition at line 275 of file sqliteconnection.cpp.

References SQLiteCursor.

PreparedStatement::Ptr SQLiteConnection::prepareStatement PreparedStatement::StatementType  type,
FieldList fields
[virtual]
 

Prepare a SQL statement and return a PreparedStatement instance.

Implements KexiDB::Connection.

Definition at line 351 of file sqliteconnection.cpp.

References d.

QString SQLiteConnection::serverErrorMsg  )  [protected, virtual]
 

KexiDB library offers detailed error numbers using errorNum() and detailed error i18n'd messages using errorMsg() - this information is not engine-dependent (almost). Use this in your application to give users more information on what's up.

This method returns (non-i18n'd !) engine-specific error message, if there was any error during last server-side operation, otherwise null string. Reimplement this for your driver

Reimplemented from KexiDB::Object.

Definition at line 346 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::errmsg, and KexiDB::Object::serverErrorMsg().

int SQLiteConnection::serverResult  )  [protected, virtual]
 

Returns:
engine-specific last server-side operation result number. Use this in your application to give users more information on what's up.
Reimplement this for your driver - default implementation just returns 0. Note that this result value is not the same as the one returned by errorNum() (Object::m_errno member)
See also:
serverErrorMsg(), drv_clearServerResult()

Reimplemented from KexiDB::Object.

Definition at line 318 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::res, and KexiDB::Object::serverResult().

QString SQLiteConnection::serverResultName  )  [protected, virtual]
 

Returns:
engine-specific last server-side operation result name, (name for serverResult()). Use this in your application to give users more information on what's up.
Reimplement this for your driver - default implementation just returns null string. Note that this result name is not the same as the error message returned by serverErorMsg() or erorMsg()
See also:
serverErrorMsg(), drv_clearServerResult()

Reimplemented from KexiDB::Object.

Definition at line 323 of file sqliteconnection.cpp.

References d, KexiDB::SQLiteConnectionInternal::res, KexiDB::Object::serverResultName(), and sqlite_error_string().


Friends And Related Function Documentation

friend class SQLiteCursor [friend]
 

Definition at line 120 of file sqliteconnection.h.

Referenced by prepareQuery().

friend class SQLiteDriver [friend]
 

Definition at line 119 of file sqliteconnection.h.


Member Data Documentation

SQLiteConnectionInternal* KexiDB::SQLiteConnection::d [protected]
 

for future extensions

Reimplemented from KexiDB::Connection.

Definition at line 117 of file sqliteconnection.h.

Referenced by drv_clearServerResult(), drv_closeDatabase(), drv_createDatabase(), drv_executeSQL(), drv_lastInsertRowID(), drv_useDatabase(), isReadOnly(), prepareStatement(), serverErrorMsg(), serverResult(), serverResultName(), and ~SQLiteConnection().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:43 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003