mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Use sqlite db file (#257)
* Use file for sqlite db * Use squeak as relative path parent for sqlite db file
This commit is contained in:
parent
5f482bf9be
commit
b8dfac1e75
4 changed files with 14 additions and 7 deletions
|
|
@ -2,7 +2,7 @@
|
|||
network=simnet
|
||||
price=1000
|
||||
max_squeaks_per_address_per_hour=5
|
||||
database=postgresql
|
||||
database=sqlite
|
||||
sqk_dir=
|
||||
enable_sync=false
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function mine_blocks {
|
|||
|
||||
cd itests
|
||||
docker-compose down --volumes
|
||||
# docker-compose build
|
||||
docker-compose build
|
||||
docker-compose up -d
|
||||
|
||||
# Initialize the blockchain with miner rewards going to the test client.
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@ def get_postgres_connection_string(user, password, host, database):
|
|||
)
|
||||
|
||||
|
||||
def get_sqlite_engine():
|
||||
def get_sqlite_engine(squeak_dir, network):
|
||||
return create_engine(
|
||||
get_sqlite_connection_string()
|
||||
get_sqlite_connection_string(squeak_dir, network)
|
||||
)
|
||||
|
||||
|
||||
def get_sqlite_connection_string():
|
||||
return "sqlite:///squeakdb.db".format()
|
||||
def get_sqlite_connection_string(squeak_dir, network):
|
||||
return "sqlite:////{}/{}.db".format(
|
||||
squeak_dir,
|
||||
network,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import sys
|
|||
import threading
|
||||
from configparser import ConfigParser
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from squeak.params import SelectParams
|
||||
|
||||
from squeakserver.admin.squeak_admin_server_handler import SqueakAdminServerHandler
|
||||
|
|
@ -79,6 +81,7 @@ def load_admin_handler(lightning_client, squeak_node):
|
|||
|
||||
def load_db(config, network):
|
||||
database = load_database(config)
|
||||
logger.info("database: " + database)
|
||||
if database == "postgresql":
|
||||
engine = get_postgres_engine(
|
||||
config["postgresql"]["user"],
|
||||
|
|
@ -88,7 +91,8 @@ def load_db(config, network):
|
|||
)
|
||||
return SqueakDb(engine, schema=network)
|
||||
elif database == "sqlite":
|
||||
engine = get_sqlite_engine()
|
||||
Path("/squeak").mkdir(parents=True, exist_ok=True)
|
||||
engine = get_sqlite_engine("squeak", network)
|
||||
return SqueakDb(engine)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue