From 09f8dd8437b136838dc56e6c7c38436ad1039934 Mon Sep 17 00:00:00 2001 From: Maas-Maarten Zeeman Date: Sun, 9 Jan 2022 11:35:46 +0100 Subject: [PATCH] Added edoc overview page --- doc/overview.edoc | 47 +++++++++++++++++++++++++++++++++++++++++++ test/esqlite_test.erl | 4 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 doc/overview.edoc diff --git a/doc/overview.edoc b/doc/overview.edoc new file mode 100644 index 0000000..5428e27 --- /dev/null +++ b/doc/overview.edoc @@ -0,0 +1,47 @@ +@author Maas-Maarten Zeeman + +@title eSqlite Documentation + +@doc + +eSqlite is a library which makes it possible to use sqlite databases in erlang. It is implemented +as a NIF, which means that the sqlite database engine is linked to the erlang virtual machine. + +
+ +== Why Sqlite? == + +Sqlite is a implementation of SQL as a library. This means that you don't run a separate SQL server +that your program communicates with, but you embed the SQL implementation directly in your program. +Sqlite stores its data in a single file. The file format is portable between different machine +architectures. It supports atomic transactions and it is possible to access the file by multiple +processes and different programs. + +
+ +== Using == + +The main api is the {@link esqlite3} module. It contains more high level api methods to use the database. + +``` +%% Open a database +{ok, Conn} = esqlite3:open("my-database.db"). +''' + +This opens a connection to a database. When the file does not exist yet, it is created. +It is possible to share the connection between different processes. + +Sqlite supports a URI database naming scheme which makes it possible to open a database +in read-only mode, or use shared memory databases. More information on this can be found at: +[https://sqlite.org/uri.html#uri_filenames_in_sqlite] + +For example: + +``` +%% Open a shared memory database with transactional capabilities +{ok, Conn} = esqlite3:open("file:memdb1?mode=memory&cache=shared"). +''' + +This opens a shared memory database. Other processes can open the same database name and +access and store data consistently. + diff --git a/test/esqlite_test.erl b/test/esqlite_test.erl index 93f079e..f500b19 100644 --- a/test/esqlite_test.erl +++ b/test/esqlite_test.erl @@ -441,8 +441,8 @@ prepare_and_close_connection_test() -> ok. backup_test() -> - {ok, Dest} = esqlite3:open("test1.sql"), - {ok, Source} = esqlite3:open("test2.sql"), + {ok, Dest} = esqlite3:open("test1.db"), + {ok, Source} = esqlite3:open("test2.db"), {ok, Backup} = esqlite3:backup_init(Dest, "main", Source, "main"), {ok, 0} = esqlite3:backup_remaining(Backup),