You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-39Lines changed: 30 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Key Features
20
20
- Authentication using [ZeroMQ Authentication Protocol (ZAP)](https://rfc.zeromq.org/spec:27/ZAP/)
21
21
- Encryption using [CurveZMQ](http://curvezmq.org/)
22
22
- Generic authorization policy during server startup
23
-
- Schedule regular backups for on-disk database (Not supported on Windows and for Python versions older than 3.7)
23
+
- Schedule regular backups for on-disk database (Currently not supported on Windows and for Python versions < 3.7)
24
24
25
25
26
26
# Install
@@ -40,14 +40,11 @@ pip install sqlite_rx
40
40
41
41
## Server
42
42
43
-
`SQLiteServer` runs in a single thread and follows an event-driven concurrency model (using `tornado's` event loop) which minimizes the cost of concurrent client connections.
43
+
`SQLiteServer` runs in a single thread and follows an event-driven concurrency model (using `tornado's` event loop) which minimizes the cost of concurrent client connections. Following snippet shows how you can start the server process.
44
44
45
45
```python
46
-
import logging.config
47
-
from sqlite_rx import get_default_logger_settings
48
46
from sqlite_rx.server import SQLiteServer
49
47
50
-
51
48
defmain():
52
49
53
50
# database is a path-like object giving the pathname
@@ -56,7 +53,6 @@ def main():
56
53
# You can use ":memory:" to open a database connection to a database
result = client.execute(script, execute_script=True)
189
-
pprint(result)
190
177
191
178
```
192
179
@@ -196,11 +183,10 @@ pprint(result)
196
183
'lastrowid': 27}
197
184
```
198
185
199
-
Select the rows inserted using the above SQL script
186
+
Select rows inserted using the above SQL script
200
187
201
188
```python
202
189
result = client.execute("SELECT * FROM users")
203
-
pprint(result)
204
190
```
205
191
206
192
```python
@@ -212,9 +198,9 @@ pprint(result)
212
198
```
213
199
214
200
215
-
### DROP a Table
201
+
### DROP a table
216
202
217
-
Note: In the default authorization setting, a client is not allowed to drop any table.
203
+
In the default authorization setting, a client is not allowed to drop any table.
218
204
219
205
```python
220
206
result = client.execute("DROP TABLE stocks")
@@ -227,11 +213,11 @@ pprint(result)
227
213
'items': []}
228
214
```
229
215
230
-
### SELECT statement; Table not present
216
+
###
231
217
```python
232
-
from pprint import pprint
233
-
result =client.execute("SELECT * FROM STUDENTS")
234
-
pprint(result)
218
+
219
+
withclient:
220
+
result= client.execute("SELECT * FROM STUDENTS")
235
221
236
222
```
237
223
@@ -241,7 +227,11 @@ pprint(result)
241
227
'items': []}
242
228
```
243
229
244
-
### Client Clean up
230
+
### SQLiteClient clean up
231
+
232
+
When you use `zeromq` sockets in a programming language like Python, objects get automatically freed for you.
233
+
However, if you want to explicitly perform clean up and free the I/O resources, there are 2 options.
234
+
You can either call the `cleanup()` method or execute queries in the context of the client i.e. `with` statement.
245
235
246
236
Call `cleanup()`
247
237
@@ -265,7 +255,10 @@ with client:
265
255
266
256
## Backup
267
257
268
-
With `sqlite-rx`, database backup can be regularly peformed. The backup function can be configured to run as a background thread during server startup. Use `backup_interval` argument to specify how frequently backup should be performed in seconds.
258
+
With `sqlite-rx`, database backup can be scheduled to run regularly during Server startup.
259
+
Under the hood, this uses SQLite's Online [Backup](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.backup) API. The Backup function runs as a daemon thread and it makes backup even while the database is being accessed by other clients.
260
+
261
+
You can specify `backup_interval` (time in seconds) to control how frequently backup should be performed.
269
262
270
263
```python
271
264
@@ -277,7 +270,6 @@ def main():
277
270
# You can use ":memory:" to open a database connection to a database
0 commit comments