added funcationilty to init a DB in case it hasn't been initialized before

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2022-04-11 20:56:09 +02:00
parent 6f62561793
commit 20860498df

View File

@ -4,6 +4,7 @@
# Code is Apache-2.0 and docs are CC-BY-4.0 # Code is Apache-2.0 and docs are CC-BY-4.0
import logging import logging
from jsonschema import SchemaError
import tarantool import tarantool
from planetmint.config import Config from planetmint.config import Config
@ -31,7 +32,10 @@ class TarantoolDB:
"transactions", "inputs", "outputs", "keys"] "transactions", "inputs", "outputs", "keys"]
def space(self, space_name: str): def space(self, space_name: str):
try:
return self.db_connect.space(space_name) return self.db_connect.space(space_name)
except tarantool.error.SchemaError:
return None
def get_connection(self): def get_connection(self):
return self.db_connect return self.db_connect