[ If there are any updates etc, I will post them on this WIP thread:-
http://forum.thegamecreators.com/?m=forum_view&t=202548&b=8 ]
Success! I have managed to create a wrapper for SQLite3. It is very much a beta version at the moment. But I have managed now to create .db sqlite3 databases and query them, create tables etc.
This is a beta of the plugin so please DO test it to destruction - no one seems to have done so yet...
Why SQLite3? Because it is serverless, self-contained, requires no configuration and has no dependencies. Took me several years to realise, but SQL is a very powerful, very simple, database language in itself. And it's fast. SQLite does not have the full SQL language but near enough. It does indices, views, multiple tables etc within Databases and the query/search capababilities are very flexible. See the link to SQL syntax below.
Current Version =
v0.6b (22/02/2013)
Update Log:-
v0.6b - 22/02/2013 - working on some more stability and trying to get DSQLITE GET TABLE COLUMN NAME to work (more than once). Also looking at speed issues.
v0.5b - 16/02/2013 - now new commands - still 73 commands
- realised schoolboy error re pointer to incorrectly named DBProCore.dll - DOh! Doh! Doh!
- in theory string returns should now work... in theory
v0.4b - 12/01/2013 - 17 new commands
- commands to allow you to change the definitions of columns in 'mapped' tables
- ommands to allow you to also change the constraints of columns in 'mapped' tables
- command to allow you to insert a new column at the start or end of a 'mapped' table or anywhere within a 'mapped' table
- command to allow you to delete any column in a 'mapped' table
- command to allow you to export a 'mapped' table as a CSV file
v0.3b - 05/01/2013 - new map/mapping of table commands
- Map Table commands and functions
- You can get strings of the column names with or without details of definitions (datatypes), constraints (not null, default value) and with or without SQL statement strings on primary keys and/or foreign keys.
- You can get string of indices in a table
- You can make a 'full' copy of a table - including all its definitions, constraints, primary and foreign keys...
v0.2b - 01/01/2013 - new functionality
- Better naming and syntax for the functions - makes more sense - allows for addition of further functions/commands;
- Got rid of the duplicate functions/commands;
- Support for 'shorthand' BEGIN TRANSACTION to COMMIT functions;
- Other functions to 'shorthand' common SQL queries and statements; and
- Support for 'shorthand' functions to assist with common PRAGMA queries like table_info, index_list, index_info and foreign_key_list.
v0.1b - 29/12/2012 - initial build
Current Command List (@ 73 commands)
DSQLITE OPEN DATABASE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SQLiteDatabaseFilename STRING, Username STRING, Password STRING)
DSQLITE CLOSE DATABASE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER,[ flagVacuumTheDatabase INTEGER])
DSQLITE SAVE DATABASE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, DatabaseFileName STRING, Username STRING, Password STRING)
DSQLITE VACUUM DATABASE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE DATABASE EXIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE GET LAST DATABASE ERROR$ - a function returning a STRING value from <*no parameters*>
DSQLITE TABLE EXIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE TRUNCATE TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE GET TABLE ROW COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE GET TABLE COLUMN NAME$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER)
DSQLITE GET TABLE COLUMN DEFINITION$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER)
DSQLITE GET TABLE COLUMN SIZE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER)
DSQLITE GET TABLE COLUMN COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE GET TABLE STRING$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER, RowNumber INTEGER)
DSQLITE GET TABLE INTEGER - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER, RowNumber INTEGER)
DSQLITE GET TABLE FLOAT - a function returning a FLOAT value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnNumber INTEGER, RowNumber INTEGER)
DSQLITE BEGIN SQL QUERY - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SQLQuery STRING)
DSQLITE BEGIN SQL QUERY PRAGMA TABLEINFO - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE BEGIN SQL QUERY PRAGMA INDEXLIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE BEGIN SQL QUERY PRAGMA INDEXINFO - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, IndexName STRING)
DSQLITE BEGIN SQL QUERY PRAGMA FOREIGNKEYLIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE BEGIN SQL QUERY SPECIFIC - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnName1 STRING, ColumnValue1 STRING,[ ColumnName2 STRING,[ ColumnValue2 STRING,[ ColumnName3 STRING,[ ColumnValue3 STRING])
DSQLITE FURTHER SQL QUERY - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, AdditionalSQLQuery STRING)
DSQLITE FIRST RECORD ROW - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE PREVIOUS RECORD ROW - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE NEXT RECORD ROW - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE LAST RECORD ROW - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE GET RECORD COLUMN NAME$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, ColumnNumber INTEGER)
DSQLITE GET RECORD COLUMN COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE GET RECORD ROW COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE GET RECORD CURRENT ROW STRING$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, ColumnNumber INTEGER)
DSQLITE GET RECORD CURRENT ROW INTEGER - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, ColumnNumber INTEGER)
DSQLITE GET RECORD CURRENT ROW FLOAT - a function returning a FLOAT value from (DSQLITEDatabaseID INTEGER, ColumnNumber INTEGER)
DSQLITE FINISH SQL QUERY - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE UPDATING SQL STATEMENT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, UpdatingSQLStatement STRING)
DSQLITE BEGIN TRANSACTION - a function returning an INTEGER value from <*no parameters*>
DSQLITE ADD TO TRANSACTION - a function returning an INTEGER value from (SQLStatementToAddToTransaction STRING)
DSQLITE GET CURRENT TRANSACTION STRING$ - a function returning a STRING value from <*no parameters*>
DSQLITE COMMIT TRANSACTION - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER)
DSQLITE CREATE TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnsDefinitionsAndConstraints STRING)
DSQLITE INSERT ROW INTO TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, SpecifiedNamedColumns STRING, SpecifiedValuesForThoseColumns STRING)
DSQLITE DELETE ROWS FROM TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, WhereConditions STRING)
DSQLITE ADD COLUMN TO TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, ColumnDefinitionAndConstraint STRING)
DSQLITE DROP TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE RENAME TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, OriginalTableName STRING, NewTableName STRING)
DSQLITE CREATE INDEX - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, IndexName STRING, TableName STRING, ColumnName STRING)
DSQLITE DROP INDEX - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, IndexName STRING)
DSQLITE MAP TABLE - a command with (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE UNMAP TABLE - a command with (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE IS TABLE MAPPED - a function returning an INTEGER value from (TableName STRING)
DSQLITE GET MAPPED TABLE COLUMN COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE GET MAPPED TABLE COLUMN DETAIL$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, TableName STRING,[ flagWithDefinitionsAndConstraints INTEGER])
DSQLITE GET MAPPED TABLE INDEX COUNT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING)
DSQLITE GET MAPPED TABLE INDEX EXIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, TableName STRING, IndexName STRING)
DSQLITE COPY MAPPED TABLE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, NewTableName STRING)
DSQLITE MAPPED TABLE COLUMN EXIST - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, SearchForColumnName STRING)
DSQLITE MAPPED TABLE COLUMN POSITION - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, SearchForColumnName STRING)
DSQLITE MAPPED TABLE GET COLUMN NAME$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE GET COLUMN DEFINITION$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE GET COLUMN DEFAULT VALUE$ - a function returning a STRING value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE GET COLUMN DEFAULT - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE GET COLUMN PRIMARY KEY - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE GET COLUMN NOT NULL - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnPosition INTEGER)
DSQLITE MAPPED TABLE SET COLUMN NAME - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, OldName STRING, NewColumnName STRING)
DSQLITE MAPPED TABLE SET COLUMN DEFINITION - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnnName INTEGER, NewColumnDefinition STRING)
DSQLITE MAPPED TABLE SET COLUMN NOT NULL - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnnName INTEGER, flagNotNull INTEGER)
DSQLITE MAPPED TABLE SET COLUMN DEFAULT VALUE - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnnName INTEGER, DefaultValue STRING)
DSQLITE MAPPED TABLE SET COLUMN PRIMARY KEY - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, ColumnnName INTEGER, flagPrimaryKey INTEGER)
DSQLITE MAPPED TABLE DELETE COLUMN - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, NameOfColumnToDelete STRING)
DSQLITE MAPPED TABLE INSERT COLUMN - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, FirstNamedColumn STRING, InsertColumnName STRING, Definition STRING, NotNull INTEGER, DefaultValue STRING, PrimaryKey INTEGER,[ flagInsertPosition INTEGER])
DSQLITE MAPPED TABLE EXPORT AS CSV - a function returning an INTEGER value from (DSQLITEDatabaseID INTEGER, SourceTableName STRING, CSVFileName STRING, flagIncludeDefinitions INTEGER, flagIncludeConstraints INTEGER)
Notes:-
- Please forgive the awful .txt help files - they were generated by a (rubbish) program I wrote to build .rcs, .inis and help files
- Please also forgive the repetition in some of the commands
- In a sense, I have over-re-invented the wheel with the commands above to simplify SQL query - but the strength is in SQL itself.
Useful Links:-
SQLite Homepage:-
http://www.sqlite.org/
SQL syntax:-
http://www.w3schools.com/sql/sql_syntax.asp
SQL as understood by SQLite:-
http://www.sqlite.org/lang.html
SQLite (freeware) Database Manager GUI I found on the web:-
http://osenxpsuite.net/?xp=3 (see bottom of web page) (can import MS Access databases/tables!) download link:-
http://link.osenxpsuite.net/?uid=homepage&id=sqlite2009pro.zip
Ideas for further development:-
- commands to allow for 'BLOB's of data ie. to allow maybe for storing of images in database...
- commands for import of CSVs in to Tables / databases - perhaps import of other formats
a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...