OpenSematicLab Controller
A controller extents a model class with functions
Entity
Bases: Entity
Source code in src/osw/controller/entity.py
4 5 6 |
|
DatabaseController
Bases: Database
Provides a sqlalchemy engine for the specified database
Source code in src/osw/controller/database.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 92 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 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
cm
instance-attribute
CredentialManager to login to the database
engine
instance-attribute
the internal sqlalchemy engine
osw
instance-attribute
an OSW instance to fetch related resources (host, server, etc.)
ConnectionConfig
dataclass
Bases: OswBaseModel
Database connection configuration
Source code in src/osw/controller/database.py
66 67 68 69 70 71 72 |
|
cm
instance-attribute
CredentialManager or direct Credential to login to the database
osw
instance-attribute
OSW instance to fetch related resources (host, server, etc.)
ConnectionString
dataclass
Bases: OswBaseModel
the sqlalchemy database connection string
Source code in src/osw/controller/database.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
database
instance-attribute
the database name / identifier
dialect
instance-attribute
sql subtype, e. g. postgres
driver
instance-attribute
specific driver, e. g. psycopg2
host
instance-attribute
the database host (ip address or domain)
password
instance-attribute
password for the login
port
instance-attribute
the database port
username
instance-attribute
username for the login
__str__()
generates the string representation
Returns:
Type | Description |
---|---|
database connection string
|
|
Source code in src/osw/controller/database.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
connect(config)
Initializes the connection to the database by creating a sqlalchemy engine
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
ConnectionConfig
|
see ConnectionConfig |
required |
Source code in src/osw/controller/database.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 |
|
execute(sql)
Executes a plain sql string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql
|
str
|
the sql string |
required |
Source code in src/osw/controller/database.py
122 123 124 125 126 127 128 129 130 131 132 133 |
|