-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
119 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b2aeb764caf50f816850626567cb58bbe65e02c45df54e8d56b7f9e5702148c4 requirements.in | ||
0f0639ee4488d0173fcd2fe6da6a991d614525066cbf04ea0932c593fed75d99 requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b2aeb764caf50f816850626567cb58bbe65e02c45df54e8d56b7f9e5702148c4 requirements.in | ||
0f0639ee4488d0173fcd2fe6da6a991d614525066cbf04ea0932c593fed75d99 requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b2aeb764caf50f816850626567cb58bbe65e02c45df54e8d56b7f9e5702148c4 requirements.in | ||
0f0639ee4488d0173fcd2fe6da6a991d614525066cbf04ea0932c593fed75d99 requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b2aeb764caf50f816850626567cb58bbe65e02c45df54e8d56b7f9e5702148c4 requirements.in | ||
0f0639ee4488d0173fcd2fe6da6a991d614525066cbf04ea0932c593fed75d99 requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ mysqlclient>=2.2.0 | |
connectorx>=0.3.0 | ||
rdkit>=2024.3.1 | ||
tqdm>=4.62.0 | ||
python-dotenv>=1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# ruff: noqa: T201 | ||
import os | ||
import urllib.parse | ||
from typing import Annotated | ||
|
||
import typer | ||
|
||
app = typer.Typer(no_args_is_help=True) | ||
|
||
|
||
@app.command() | ||
def get_uri_from_env( | ||
db_name: Annotated[str | None, typer.Argument(..., help="Database name")] = None, | ||
): | ||
""" | ||
Get connection URI from environment variables for .env file. | ||
The following environment variables are required: | ||
- POSTGRESQL_HOST (default: localhost) | ||
- POSTGRESQL_PORT (default: 5432) | ||
- POSTGRESQL_USER | ||
- POSTGRESQL_PASSWORD | ||
""" | ||
from dotenv import find_dotenv, load_dotenv | ||
|
||
dotenv_path = find_dotenv(usecwd=True) | ||
if dotenv_path != "": | ||
load_dotenv(dotenv_path) | ||
|
||
host = os.getenv("POSTGRESQL_HOST") | ||
if host is None: | ||
host = "localhost" | ||
port = os.getenv("POSTGRESQL_PORT") | ||
if port is None: | ||
port = "5432" | ||
|
||
user = os.getenv("POSTGRESQL_USER") | ||
if user is None: | ||
print("❌ POSTGRESQL_USER is required.") | ||
typer.Exit(code=1) | ||
return | ||
password = os.getenv("POSTGRESQL_PASSWORD") | ||
if password is None: | ||
print("❌ POSTGRESQL_PASSWORD is required.") | ||
typer.Exit(code=1) | ||
return | ||
|
||
if db_name is not None: | ||
print( | ||
f"postgresql://{user}:{urllib.parse.quote_plus(password)}@{host}:{port}/{db_name}" | ||
) | ||
else: | ||
print(f"postgresql://{user}:{urllib.parse.quote_plus(password)}@{host}:{port}") | ||
|
||
|
||
def main(): | ||
app() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |