|
@@ -88,6 +88,8 @@ type
|
|
|
constructor Create(AOwner : TComponent); override;
|
|
|
procedure GetFieldNames(const TableName : string; List : TStrings); override;
|
|
|
function GetConnectionInfo(InfoType:TConnInfoType): string; override;
|
|
|
+ procedure CreateDB; override;
|
|
|
+ procedure DropDB; override;
|
|
|
function GetInsertID: int64;
|
|
|
// See http://www.sqlite.org/c3ref/create_collation.html for detailed information
|
|
|
// If eTextRep=0 a default UTF-8 compare function is used (UTF8CompareCallback)
|
|
@@ -334,12 +336,12 @@ begin
|
|
|
ABlobBuf^.BlobBuffer^.Size := int1;
|
|
|
end;
|
|
|
|
|
|
-Function TSQLite3Connection.AllocateTransactionHandle: TSQLHandle;
|
|
|
+function TSQLite3Connection.AllocateTransactionHandle: TSQLHandle;
|
|
|
begin
|
|
|
result:= tsqlhandle.create;
|
|
|
end;
|
|
|
|
|
|
-Function TSQLite3Connection.AllocateCursorHandle: TSQLCursor;
|
|
|
+function TSQLite3Connection.AllocateCursorHandle: TSQLCursor;
|
|
|
|
|
|
Var
|
|
|
Res : TSQLite3Cursor;
|
|
@@ -350,7 +352,7 @@ begin
|
|
|
Result:=Res;
|
|
|
end;
|
|
|
|
|
|
-Procedure TSQLite3Connection.DeAllocateCursorHandle(var cursor: TSQLCursor);
|
|
|
+procedure TSQLite3Connection.DeAllocateCursorHandle(var cursor: TSQLCursor);
|
|
|
begin
|
|
|
freeandnil(cursor);
|
|
|
end;
|
|
@@ -778,15 +780,15 @@ end;
|
|
|
|
|
|
procedure TSQLite3Connection.DoInternalConnect;
|
|
|
var
|
|
|
- str1: string;
|
|
|
+ filename: ansistring;
|
|
|
begin
|
|
|
Inherited;
|
|
|
- if Length(databasename)=0 then
|
|
|
+ if DatabaseName = '' then
|
|
|
DatabaseError(SErrNoDatabaseName,self);
|
|
|
- if (SQLiteLoadedLibrary='') then
|
|
|
+ if SQLiteLoadedLibrary = '' then
|
|
|
InitializeSqlite(SQLiteDefaultLibrary);
|
|
|
- str1:= databasename;
|
|
|
- checkerror(sqlite3_open(pchar(str1),@fhandle));
|
|
|
+ filename := DatabaseName;
|
|
|
+ checkerror(sqlite3_open(PAnsiChar(filename),@fhandle));
|
|
|
if (Length(Password)>0) and assigned(sqlite3_key) then
|
|
|
checkerror(sqlite3_key(fhandle,PChar(Password),StrLen(PChar(Password))));
|
|
|
if Params.IndexOfName('foreign_keys') <> -1 then
|
|
@@ -997,6 +999,25 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TSQLite3Connection.CreateDB;
|
|
|
+var filename: ansistring;
|
|
|
+begin
|
|
|
+ CheckDisConnected;
|
|
|
+ filename := DatabaseName;
|
|
|
+ try
|
|
|
+ checkerror(sqlite3_open(PAnsiChar(filename),@fhandle));
|
|
|
+ finally
|
|
|
+ sqlite3_close(fhandle);
|
|
|
+ fhandle := nil;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TSQLite3Connection.DropDB;
|
|
|
+begin
|
|
|
+ CheckDisConnected;
|
|
|
+ DeleteFile(DatabaseName);
|
|
|
+end;
|
|
|
+
|
|
|
function UTF8CompareCallback(user: pointer; len1: longint; data1: pointer; len2: longint; data2: pointer): longint; cdecl;
|
|
|
var S1, S2: AnsiString;
|
|
|
begin
|