wxSQLite

From WxWiki
Jump to: navigation, search

A wxWidgets wrapper around the sqlite database.

NOTE: ( This page is for SQL 2.x. For SQL 3, see http://wxcode.sourceforge.net/components/wxsqlite3/ )

External Links

Used in:

  • SQLiteCC is a wxWidgets & wxSQLite based program and could be useful for a reference program.

Features

  • Opening Database
  • Thread safety
  • Fetch style access to SQL Query results
  • Tested under windows, but should work under any system that compiles wxWidgets (ie. Linux, Mac etc) (Linus McCabe: I've used it on Linux for a few days without problems)

Alternatives

  • Metakit is also a good, small, crossplatform database.
  • ctree c-tree from FairCom runs on a lot of platforms. I used it on Mac 68K a few years ago. Their Web site says to call for details on that platform, they probably send you an older version for 68K. But it does run on Mac PPC System 7-9. Plus Windows & Linux.
  • Firebird is a cross-platform database that can run embedded or as a client/server database. Originally based on Borland's Interbase database. To get a better idea of the project activity go to the site http://www.ibphoenix.com/
  • wxSQLite3 wxWindows wrapper for SQLite 3.x. Inspired by wxSQLite and CppSQLite, supporting most features of SQLite 3 including user-defined functions.

Functions

Please note that the following is incomplete. Please contribute your knowledge to help others.

wxSQLiteDatabase

wxSQLiteDatabase::wxSQLiteDatabase

wxSQLiteDatabase (wxString filename)

filename is the database file to open. If the file does not exist, it will be created.


wxSQLiteDatabase::~wxSQLiteDatabase

~wxSQLiteDatabase ()

Destructor. Calls Close().


wxSQLiteDatabase::Open

bool Open (wxString filename)

filename is the database file to open. If the file does not exist, it will be created.


wxSQLiteDatabase::Close

bool Close ()

Closes the current database file.


wxSQLiteDatabase::TableExists

bool TableExists (wxString table-name)

Check if a table exists.

table-name is the name of the table to check.


wxSQLiteDatabase::BeginTransaction

void BeginTransaction ()


wxSQLiteDatabase::Commit

void Commit ()


wxSQLiteDatabase::Rollback

void Rollback ()


wxSQLiteDatabase::LastInsertRowId

int LastInsertRowId ()

Obtain the value used for an auto_increment field after an INSERT.


wxSQLiteQueryResult

Derived from wxSQLiteQueryBase

wxSQLiteQueryResult::wxSQLiteQueryResult

wxSQLiteQueryResult (wxSQLiteDatabase& db)

db is the reference to the wxSQLiteDatabase instance.


wxSQLiteQueryResult::~wxSQLiteQueryResult

~wxSQLiteQueryResult ()

Destructor. Calls wxsqlite_free_table(result).


wxSQLiteQueryResult::Execute

bool Execute (const char *sql, ...)

Execute SQL query. Returns TRUE if the query was executed successfully, otherwise FALSE.


wxSQLiteQueryResult::NumChanges

int NumChanges ()


wxSQLiteQueryResult::NumRows

int NumRows ()


wxSQLiteQueryResult::NumCols

int NumCols ()


wxSQLiteQueryResult::GetFieldName

char *GetFieldName (int fieldIndex)

Returns the name of the field at index fieldIndex, where indexes start at 0.