/[eiffelstudio]/branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/relational/database_wrapper/sqlite/ps_sqlite_database.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/relational/database_wrapper/sqlite/ps_sqlite_database.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88969 - (show annotations)
Fri Jun 22 11:53:00 2012 UTC (7 years, 4 months ago) by romanschmocker
File size: 2282 byte(s)
Changed structure in the ABEL library repository - e.g. pre-built backends are now collected in their own cluster
1 note
2 description: "Wrapper for a SQLite database."
3 author: "Roman Schmocker"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 PS_SQLITE_DATABASE
9
10 inherit
11 PS_SQL_DATABASE_ABSTRACTION
12
13 create
14 make
15
16 feature {PS_EIFFELSTORE_EXPORT}
17
18 acquire_connection: PS_SQL_CONNECTION_ABSTRACTION
19 -- Get a new connection.
20 -- The transaction isolation level of th new connection is the same as in `Current.transaction_isolation_level', and autocommit is disabled.
21 local
22 -- sqlite_connection: SQLITE_DATABASE
23 do
24 -- It only works with one connection, so create a wrappe around it and return that.
25 create {PS_SQLITE_CONNECTION} Result.make (unique_connection)
26
27 -- create sqlite_connection.make_create_read_write (database_location)
28 -- sqlite_connection.begin_transaction (False)
29 -- create {PS_SQLITE_CONNECTION} Result.make (sqlite_connection)
30
31 end
32
33 release_connection (a_connection:PS_SQL_CONNECTION_ABSTRACTION)
34 -- Release connection `a_connection'
35 do
36 -- There is only one connection which should not be closed, therefore
37 do_nothing
38
39 -- check attached {PS_SQLITE_CONNECTION} a_connection as conn then
40 -- conn.internal_connection.rollback
41 -- conn.internal_connection.close
42 -- end
43 end
44
45
46 set_transaction_isolation_level (a_level: PS_TRANSACTION_ISOLATION_LEVEL)
47 -- Set the transaction isolation level `a_level' for all connections that are acquired in the future
48 -- Note: Some databases don't support all transaction isolation levels. In that case, a higher isolation level is chosen.
49 do
50 -- Serializable is the default, and it can't be changed.
51 end
52
53 close_connections
54 -- Close all currently open connections
55 do
56 unique_connection.rollback
57 unique_connection.close
58 end
59
60 feature {NONE} -- Initialization
61
62 make (database_file: STRING)
63 -- Initialization for `Current'.
64 do
65 create transaction_isolation_level
66 transaction_isolation_level:= transaction_isolation_level.serializable -- This is the default in SQLite
67
68 database_location:= database_file
69
70 create unique_connection.make_create_read_write (database_location)
71 unique_connection.begin_transaction (false)
72 end
73
74 database_location: STRING
75 -- The location of the database file
76
77 unique_connection: SQLITE_DATABASE
78 -- The only connection to the database
79 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23