1 ------------------------------------------------------------------------------
4 -- Copyright (C) 2006 --
5 -- Pascal Obry - Olivier Ramonat --
7 -- This library is free software; you can redistribute it and/or modify --
8 -- it under the terms of the GNU General Public License as published by --
9 -- the Free Software Foundation; either version 2 of the License, or (at --
10 -- your option) any later version. --
12 -- This library is distributed in the hope that it will be useful, but --
13 -- WITHOUT ANY WARRANTY; without even the implied warranty of --
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
15 -- General Public License for more details. --
17 -- You should have received a copy of the GNU General Public License --
18 -- along with this library; if not, write to the Free Software Foundation, --
19 -- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --
20 ------------------------------------------------------------------------------
26 DB_Error
: exception renames DB
.DB_Error
;
28 type Handle
is new DB
.Handle
with private;
30 In_Memory_Database
: constant String := ":memory:";
31 -- When the database name is ":memory:", a private in-memory
32 -- database is created for the connection. This in-memory
33 -- database will vanish when the database connection is closed.
35 overriding
procedure Connect
38 User
: in String := "";
39 Password
: in String := "");
40 -- Open the database named Name
42 overriding
procedure Close
(DB
: in out Handle
);
43 -- Close the current database
47 overriding
procedure Begin_Transaction
(DB
: in Handle
);
48 -- Start a new transaction, do not support embedded transactions
50 overriding
procedure Commit
(DB
: in Handle
);
51 -- Commit the current transaction
53 overriding
procedure Rollback
(DB
: in Handle
);
54 -- Rollback the current transaction
58 type Iterator
is new DB
.Iterator
with private;
60 overriding
procedure Prepare_Select
62 Iter
: in out Standard
.DB
.Iterator
'Class;
64 -- Prepare a select statement (SQL must be a select command)
66 overriding
procedure Get_Line
67 (Iter
: in out Iterator
;
68 Result
: out String_Vectors
.Vector
);
69 -- Returns the current row and move to the next one
71 overriding
function More
(Iter
: in Iterator
) return Boolean;
72 -- Returns True if there is more data (row) to fetch
74 overriding
procedure End_Select
(Iter
: in out Iterator
);
76 overriding
procedure Execute
(DB
: in Handle
; SQL
: in String);
77 -- Execute SQL request into DB
79 overriding
function Last_Insert_Rowid
(DB
: in Handle
) return String;
80 -- Returns the Id of the last inserted row id
84 type Handle
is new DB
.Handle
with record
85 H
: GNU
.DB
.SQLite3
.Handle
;
88 type Iterator
is new DB
.Iterator
with record
90 S
: aliased GNU
.DB
.SQLite3
.Statement
;