From c208691d98e5db997d0d4272d2ae4a911fd2f358 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Dec 2024 13:21:34 -0500 Subject: [PATCH] Fix bug when creating a sqlite database via Felis --- astrodbkit/astrodb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astrodbkit/astrodb.py b/astrodbkit/astrodb.py index c79c7d8..7b89545 100644 --- a/astrodbkit/astrodb.py +++ b/astrodbkit/astrodb.py @@ -223,7 +223,8 @@ def create_database(connection_string, drop_tables=False, felis_schema=None): # Schema handling for various database types if connection_string.startswith("sqlite"): - db_name = connection_string.split("/")[-1] + # Get the full path to the file as otherwise the DB is only created in the working directory + db_name = connection_string.replace("sqlite:///", "") with engine.begin() as conn: conn.execute(text(f"ATTACH '{db_name}' AS {schema_name}")) elif connection_string.startswith("postgres"):