Skip to content

Commit 72ddc06

Browse files
committed
Update README
Add DSN Connections string table. [ci skip]
1 parent a587d7d commit 72ddc06

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Supported Golang version:
1919

2020
- [Installation](#installation)
2121
- [API Reference](#api-reference)
22+
- [Connection String](#connection-string)
2223
- [Features](#features)
2324
- [Compilation](#compilation)
2425
- [Android](#android)
@@ -53,6 +54,36 @@ API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite
5354

5455
Examples can be found under the [examples](./_example) directory
5556

57+
# Connection String
58+
59+
When creating a new SQLite database or connection to an existing one, with the file name additional options can be given.
60+
This is also known as a DSN string. (Data Source Name).
61+
62+
Options are append after the filename of the SQLite database.
63+
The database filename and options are seperated by an `?` (Question Mark).
64+
65+
This also applies when using an in-memory database instead of a file.
66+
67+
Options can be given using the following format: `KEYWORD=VALUE` and multiple options can be combined with the `&` ampersand.
68+
69+
This library supports dsn options of SQLite itself and provides additional options.
70+
71+
| Name | Key | Value(s) | Description |
72+
|------|-----|----------|-------------|
73+
| Shared-Cache Mode | cache | <ul><li>shared</li><li>private</li></ul> | Set cache mode for more information see [sqlite.org](https://www.sqlite.org/sharedcache.html) |
74+
| Time Zone Location | _loc | auto | Specify location of time format. |
75+
| Busy Timeout | _busy_timeout | `int` | Specify value for sqlite3_busy_timeout. |
76+
| Transaction Lock | _txlock | <ul><li>immediate</li><li>deferred</li><li>exclusive</li></ul> | Specify locking behavior for transactions. |
77+
| Foreign Keys | _foreign_keys | <ul><li>0</li><li>1</li></ul> | Enable or disable enforcement of foreign keys. |
78+
| Recursive Triggers | _recursive_triggers | <ul><li>0</li><li>1</li></ul> | Enable or disable recursive triggers. |
79+
| Mutex Locking | _mutex | <ul><li>no</li><li>full</li></ul> | Specify mutex mode. |
80+
81+
## DSN Examples
82+
83+
```
84+
file:test.db?cache=shared&mode=memory
85+
```
86+
5687
# Features
5788

5889
This package allows additional configuration of features available within SQLite3 to be enabled or disabled by golang build constraints also known as build `tags`.

0 commit comments

Comments
 (0)