Support for AS5 databases - #325
Conversation
* More robustly supports using `postgresql://` URIs for connection, including parsing the URI and extracting connection parameters. * Supports connecting to the PostgreSQL database using a socket connection instead of TCP/IP. * Type all methods and attributes. * Streamline the connection logic without (I think) changes to its current behaviour. * Deprecate `connect_from_parameters` in favour of `connect`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
==========================================
- Coverage 89.54% 89.54% -0.01%
==========================================
Files 46 46
Lines 26812 26832 +20
Branches 478 490 +12
==========================================
+ Hits 24010 24026 +16
+ Misses 2765 2755 -10
- Partials 37 51 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| if dbname_or_uri.startswith("postgresql"): | ||
| return dbname_or_uri | ||
| assert self.engine is not None |
|
|
||
| self.set_profile(profile=profile, connect=False) | ||
| if is_uri(dbname_or_uri): | ||
| assert isinstance(dbname_or_uri, str) |
There was a problem hiding this comment.
They are a few asserts in here. Can we raise an error instead? Maybe a ValueError or TypeError here?
|
With the connection streamlining, and socket stuff, what is the current precedence order for connecting? And preferred method? We may want to do a pass on the docs. |
|
I have been trying to not change the user-facing behaviour as I streamline, but that should be checked, and I'm in the process of adding tests. One thing that's still there because I didn't want to break it (but may be worth discussing) is that one can override a loaded profile by passing arguments to By default |
|
I was wondering if we were planning on keeping the profiles around. I think it can be confusing as to if one needs a profile or not to use I think it's good we're simplifying the connection, with |
|
Profiles make a lot of operationns software MUCH easier. Jose and I both have code that needs to run at both observatories and at Utah, so setting the database connection in the background based on FQDN is quite convenient. Although, it can be a bit unwieldy at Utah since they change the hostnames all the time, and there isn't necessarily a consistent naming convention across nodes. I was actually considering asking y'all if we could set Utah (i.e. operations) as the default profile if the regex doesn't find anything? Feels like it wouldn't affect most people if they're setting connections manually, but it'd help me whip some inherited software into shape much more quickly. |
|
I like the ability of setting a profile, and it's nice that in "most" situations sdssdb just connects to the database with the right connection. But then I'm also not sure how often that would just work fine without profiles since we normally connect to localhost. I lean towards leaving the profiles, but it can also be confusing mixing profiles with override parameters, and maybe there is a better way to handle those. One thing I added in this streamlining is a more verbose warning when the connection fails that outputs the connection parameters used; I have found myself very confused a number of times trying to figure out why a connection was failing and what sdssdb was trying to do. |
postgresql://URIs for connection, including parsing the URI and extracting connection parameters.connect_from_parametersin favour ofconnect.