aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/lib/SQLite/lazarustest.lpr
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-09-19 23:40:11 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-09-19 23:40:11 +0000
commit77ac0ce6d082dfc0bfd2c9a7efaa304aadfe3683 (patch)
tree2e573d8856e6c76cbe91b24e989ffd4de5235eda /Game/Code/lib/SQLite/lazarustest.lpr
parent4e9a191776560d0bc669800461948e5b9b206679 (diff)
downloadusdx-77ac0ce6d082dfc0bfd2c9a7efaa304aadfe3683.tar.gz
usdx-77ac0ce6d082dfc0bfd2c9a7efaa304aadfe3683.tar.xz
usdx-77ac0ce6d082dfc0bfd2c9a7efaa304aadfe3683.zip
tested sqlite3 in lazarus - linux..
working :) updated requirements text with instructions on how to get dev libraries for linux build. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@407 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/lib/SQLite/lazarustest.lpr')
-rw-r--r--Game/Code/lib/SQLite/lazarustest.lpr160
1 files changed, 81 insertions, 79 deletions
diff --git a/Game/Code/lib/SQLite/lazarustest.lpr b/Game/Code/lib/SQLite/lazarustest.lpr
index 61b7c748..bc005bec 100644
--- a/Game/Code/lib/SQLite/lazarustest.lpr
+++ b/Game/Code/lib/SQLite/lazarustest.lpr
@@ -1,79 +1,81 @@
-program lazarustest;
-
-uses
- SQLiteTable3 in 'SQLiteTable3.pas',
- SQLite3 in 'SQLite3.pas',
- sysutils;
-
-
-procedure DoTest();
-var
- slDBpath : string;
- sldb : TSQLiteDatabase;
- sltb : TSQLIteTable;
- sSQL : String;
- Notes : String;
-
-begin
- slDBPath := ExtractFilepath( paramstr(0) ) + 'test.db';
- sldb := TSQLiteDatabase.Create(slDBPath);
-
- try
-
- if sldb.TableExists('testTable') then
- begin
- sSQL := 'DROP TABLE testtable';
- sldb.execsql(sSQL);
- end;
-
- sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,';
- sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);';
- sldb.execsql(sSQL);
-
- sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);');
-
- //begin a transaction
- sldb.BeginTransaction;
-
- sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");';
- //do the insert
- sldb.ExecSQL(sSQL);
-
- sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");';
- //do the insert
- sldb.ExecSQL(sSQL);
-
- //end the transaction
- sldb.Commit;
-
- //query the data
- sltb := slDb.GetTable('SELECT * FROM testtable');
- try
-
- if sltb.Count > 0 then
- begin
- //display first row
- writeln( sltb.FieldAsString(sltb.FieldIndex['Name']) );
- writeln( inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID'])) );
- writeln( floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number'])) );
- end;
-
- finally
- sltb.Free;
- end;
-
- finally
- sldb.Free;
- end;
-
-end;
-
-begin
- try
- DoTest();
- writeln( 'SqlLite3 unit IS lazarus compatible' );
- except
- writeln( 'ERROR : SqlLite3 unit is NOT lazarus compatible' );
- end;
-end.
-
+program lazarustest;
+
+uses
+ SQLiteTable3 in 'SQLiteTable3.pas',
+ SQLite3 in 'SQLite3.pas',
+ sysutils;
+
+
+procedure DoTest();
+var
+ slDBpath : string;
+ sldb : TSQLiteDatabase;
+ sltb : TSQLIteTable;
+ sSQL : String;
+ Notes : String;
+
+begin
+ // needed for linux build.
+
+ slDBPath := ExtractFilepath( paramstr(0) ) + 'test.db';
+ sldb := TSQLiteDatabase.Create(slDBPath);
+
+ try
+
+ if sldb.TableExists('testTable') then
+ begin
+ sSQL := 'DROP TABLE testtable';
+ sldb.execsql(sSQL);
+ end;
+
+ sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,';
+ sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);';
+ sldb.execsql(sSQL);
+
+ sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);');
+
+ //begin a transaction
+ sldb.BeginTransaction;
+
+ sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");';
+ //do the insert
+ sldb.ExecSQL(sSQL);
+
+ sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");';
+ //do the insert
+ sldb.ExecSQL(sSQL);
+
+ //end the transaction
+ sldb.Commit;
+
+ //query the data
+ sltb := slDb.GetTable('SELECT * FROM testtable');
+ try
+
+ if sltb.Count > 0 then
+ begin
+ //display first row
+ writeln( sltb.FieldAsString(sltb.FieldIndex['Name']) );
+ writeln( inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID'])) );
+ writeln( floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number'])) );
+ end;
+
+ finally
+ sltb.Free;
+ end;
+
+ finally
+ sldb.Free;
+ end;
+
+end;
+
+begin
+ try
+ DoTest();
+ writeln( 'SqlLite3 unit IS lazarus compatible' );
+ except
+ writeln( 'ERROR : SqlLite3 unit is NOT lazarus compatible' );
+ end;
+end.
+