XMRigDatabase
A class for handling database operations related to the XMRig miner.
Attributes:
Name | Type | Description |
---|---|---|
_engines |
Dict[str, Engine]
|
A dictionary to store database engines. |
Source code in xmrig/db.py
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
check_table_exists(db_url, table_name)
classmethod
Checks if the table exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_url
|
str
|
Database URL for creating the engine. |
required |
table_name
|
str
|
Name of the table to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the table exists, False otherwise. |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If an error occurs while checking if the table exists. |
Source code in xmrig/db.py
delete_all_miner_data_from_db(miner_name, db_url)
classmethod
Deletes all tables related to a specific miner from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
miner_name
|
str
|
The unique name of the miner. |
required |
db_url
|
str
|
Database URL for creating the engine. |
required |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If an error occurs while deleting the miner data from the database. |
Source code in xmrig/db.py
fallback_to_db(table_name, keys, db_url)
classmethod
Retrieves the data from the database using the provided table name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
Union[str, List[str]]
|
The name of the table or list of table names to use to retrieve the data. |
required |
keys
|
List[Union[str, int]]
|
The keys to use to retrieve the data. |
required |
db_url
|
str
|
The Database URL for creating the engine. |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The retrieved data, or "N/A" if not available. |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If an error occurs while retrieving data from the database. |
Source code in xmrig/db.py
get_db(db_url)
classmethod
Returns the database engine for the specified database URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_url
|
str
|
Database URL for creating the engine. |
required |
Returns:
Name | Type | Description |
---|---|---|
Engine |
Engine
|
SQLAlchemy engine instance. |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If the database engine does not exist. |
Source code in xmrig/db.py
init_db(db_url)
classmethod
Initializes the database engine, if it already exists, it returns the existing engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_url
|
str
|
Database URL for creating the engine. |
required |
Returns:
Name | Type | Description |
---|---|---|
Engine |
Engine
|
SQLAlchemy engine instance. |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If an error occurs while initializing the database. |
Source code in xmrig/db.py
insert_data_to_db(json_data, table_name, db_url)
classmethod
Inserts JSON data into the specified database table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
Dict[str, Any]
|
JSON data to insert. |
required |
table_name
|
str
|
Name of the table to insert data into. |
required |
db_url
|
str
|
Database URL for creating the engine. |
required |
Raises:
Type | Description |
---|---|
XMRigDatabaseError
|
If an error occurs while inserting data into the database. |