Skip to content

Commit

Permalink
Log catalog init (#714)
Browse files Browse the repository at this point in the history
* print db init output to log

* remove in_memory setting
  • Loading branch information
dylanmcreynolds authored Apr 9, 2024
1 parent 58bc300 commit 9a90328
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tiled/catalog/adapter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections
import importlib
import itertools as it
import logging
import operator
import os
import re
Expand Down Expand Up @@ -62,6 +63,8 @@
from .explain import ExplainAsyncSession
from .utils import compute_structure_id

logger = logging.getLogger(__name__)

DEFAULT_ECHO = bool(int(os.getenv("TILED_ECHO_SQL", "0") or "0"))
INDEX_PATTERN = re.compile(r"^[A-Za-z0-9_-]+$")

Expand Down Expand Up @@ -1281,11 +1284,17 @@ def from_uri(
import subprocess

# TODO Check if catalog exists.
subprocess.run(
process = subprocess.run(
[sys.executable, "-m", "tiled", "catalog", "init", "--if-not-exists", uri],
capture_output=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
# Capture stdout and stderr from the subprocess and write to logging
stdout = process.stdout.decode()
stderr = process.stderr.decode()
logging.info(f"Subprocess stdout: {stdout}")
logging.error(f"Subprocess stderr: {stderr}")
if not SCHEME_PATTERN.match(uri):
# Interpret URI as filepath.
uri = f"sqlite+aiosqlite:///{uri}"
Expand Down

0 comments on commit 9a90328

Please sign in to comment.