Skip to content

Conversation

@kelle
Copy link
Contributor

@kelle kelle commented Nov 5, 2025

This deprecates the load_astrodb function and replaces it with build_db_from_json and read_db_from_file.

It also implements the use of a database.toml file for storing the database settings.

Tests will only pass with the improve_load_astrodb branch of the template. https://github.com/astrodbtoolkit/astrodb_utils/actions/runs/19118250344

Companion PR: astrodbtoolkit/astrodb-template-db#176

TODO:

  • write some docs for new functions
  • document the database.toml file

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 74.21875% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.54%. Comparing base (b52d147) to head (ba19ec8).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
tests/conftest.py 40.74% 15 Missing and 1 partial ⚠️
astrodb_utils/loaders.py 77.04% 8 Missing and 6 partials ⚠️
astrodb_utils/utils.py 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
+ Coverage   71.46%   71.54%   +0.08%     
==========================================
  Files          17       19       +2     
  Lines        1549     1652     +103     
  Branches      203      212       +9     
==========================================
+ Hits         1107     1182      +75     
- Misses        361      382      +21     
- Partials       81       88       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dr-rodriguez
Copy link
Collaborator

Example if you wanted to use dataclasses for handling the settings information:

@dataclass
class ConnectionInfo:
    # Data class for storing connection information

    server: str
    database: str
    conn: Connection | None
    schema: str | None
    conn_type: str | None

    def __post_init__(self):
        # Validation checks
        if self.server is None or self.server.upper() == "NONE":
            raise ValueError("Server is required")
        if self.database is None or self.database.upper() == "NONE":
            raise ValueError("Database is required")
        if self.schema is None or self.schema.upper() in ["NONE", "DEFAULT"]:
            # If no schema is specified, default to dbo
            self.schema = "dbo"
        if self.conn_type is None or self.conn_type.upper() in ["NONE", "DEFAULT"]:
            # If no connection type is specified, default to ODBC
            self.conn_type = "ODBC"
        if self.conn_type.upper() not in ["ODBC", "POSTGRES", "GREENPLUM", "SQLITE"]:
            # Check that connection type is among a valid list
            raise ValueError(f"Invalid connection type: {self.conn_type}")

Copy link
Contributor Author

@kelle kelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some quick thoughts.

dr-rodriguez and others added 6 commits November 11, 2025 17:42
Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
@kelle kelle merged commit 81b4361 into main Dec 2, 2025
9 checks passed
@kelle kelle deleted the improve_load_astrodb branch December 2, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants