mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
Added connection dict object, where is stored all connections
This commit is contained in:
parent
94d82a3e68
commit
38db28b92a
@ -4,11 +4,26 @@ from planetmint.backend.tarantool.utils import run
|
||||
|
||||
|
||||
class TarantoolDB:
|
||||
def __init__(self, host, port, username, password):
|
||||
self.conn = tarantool.connect(host=host, port=port, user=username, password=password)
|
||||
def __init__(self, host: str, port: int, username: str, password: str):
|
||||
self.db_connect = tarantool.connect(host=host, port=port, user=username, password=password)
|
||||
self._spaces = {
|
||||
"abci_chains": self.db_connect.space("abci_chains"),
|
||||
"assets": self.db_connect.space("assets"),
|
||||
"blocks": {"blocks": self.db_connect.space("blocks"), "blocks_tx": self.db_connect.space("blocks_tx")},
|
||||
"elections": self.db_connect.space("elections"),
|
||||
"meta_data": self.db_connect.space("meta_data"),
|
||||
"pre_commits": self.db_connect.space("pre_commits"),
|
||||
"validators": self.db_connect.space("validators"),
|
||||
"transactions": {
|
||||
"transactions": self.db_connect.space("transactions"),
|
||||
"inputs": self.db_connect.space("inputs"),
|
||||
"outputs": self.db_connect.space("outputs"),
|
||||
"keys": self.db_connect.space("keys")
|
||||
}
|
||||
}
|
||||
|
||||
def connect_to_sapce(self, spacename):
|
||||
self.conn.space(spacename)
|
||||
def get_space(self, spacename: str):
|
||||
return self._spaces[spacename]
|
||||
|
||||
|
||||
def init_tarantool():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user