sshfsdb
plantdb.commons.sshfsdb Link
This module implement a database as a file structure on a remote server using SSHFS.
SSHFSDB Link
SSHFSDB(basedir, remotedir=None)
Bases: FSDB
Subclass of FSDB that first mounts a remote directory using SSHFS.
Implementation of a database on a remote file system.
Attributes:
| Name | Type | Description |
|---|---|---|
basedir |
str
|
Path to the local directory where to mount the remote directory. |
remotedir |
(str, optional)
|
Path to the remote directory containing the database.
Should be in the format |
scans |
list
|
The list of |
is_connected |
bool
|
|
Database constructor.
Mount remotedir directory on the basedir directory and load accessible Scan objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basedir
|
str
|
Path to local directory of the database |
required |
remotedir
|
str
|
Path to the remote directory containing the database.
Should be in the format |
None
|
Examples:
>>> # EXAMPLE 1: Use a temporary dummy database:
>>> from plantdb.commons.sshfsdb import SSHFSDB
>>> db = SSHFSDB("db", "someone@example.com:/data")
>>> print(db.basedir)
db
>>> print(db.remotedir)
someone@example.com:/data
>>> # Now connecting to this remote DB...
>>> db.connect()
>>> # ...allows to create new `Scan` in it:
>>> new_scan = db.create_scan("007")
>>> print(type(new_scan))
<class 'plantdb.commons.fsdb.core.Scan'>
>>> db.disconnect()
Source code in plantdb/commons/sshfsdb.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
connect Link
connect(login=None, unsafe=False)
Connect to the remote database.
Handle DB "locking" system by adding a LOCK_FILE_NAME file in the DB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
login
|
bool
|
UNUSED |
None
|
Examples:
>>> from plantdb.commons.sshfsdb import SSHFSDB
>>> db = SSHFSDB("db", "someone@example.com:/data")
>>> print(db.is_connected)
False
>>> db.connect()
>>> print(db.is_connected)
True
Source code in plantdb/commons/sshfsdb.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
disconnect Link
disconnect()
Disconnect from the database.
Handle DB "locking" system by removing the LOCK_FILE_NAME file from the DB.
Examples:
>>> from plantdb.commons.sshfsdb import SSHFSDB
>>> db = SSHFSDB("db", "someone@example.com:/data")
>>> print(db.is_connected)
False
>>> db.connect()
>>> print(db.is_connected)
True
>>> db.disconnect()
>>> print(db.is_connected)
False
Source code in plantdb/commons/sshfsdb.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |