-
Notifications
You must be signed in to change notification settings - Fork 7
Improve database loading functions #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* first working draft * always pull the latest template * only pull if needed * two functions * add gitpython to dependencies
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
|
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}") |
kelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some quick thoughts.
Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
This deprecates the
load_astrodbfunction and replaces it withbuild_db_from_jsonandread_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_astrodbbranch of the template. https://github.com/astrodbtoolkit/astrodb_utils/actions/runs/19118250344Companion PR: astrodbtoolkit/astrodb-template-db#176
TODO:
database.tomlfile