hockey-blast-common-lib 0.1.18__tar.gz → 0.1.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/PKG-INFO +1 -1
- hockey_blast_common_lib-0.1.20/hockey_blast_common_lib/db_connection.py +44 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/utils.py +2 -2
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/setup.py +1 -1
- hockey_blast_common_lib-0.1.18/hockey_blast_common_lib/db_connection.py +0 -43
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/MANIFEST.in +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/README.md +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/__init__.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_human_stats.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/models.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/options.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/stats_models.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/wsgi.py +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
- {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/setup.cfg +0 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
import os
|
2
|
+
from sqlalchemy import create_engine
|
3
|
+
from sqlalchemy.orm import sessionmaker
|
4
|
+
|
5
|
+
# Database connection parameters per organization
|
6
|
+
DB_PARAMS = {
|
7
|
+
"frontend": {
|
8
|
+
"dbname": os.getenv("DB_NAME", "hockey_blast"),
|
9
|
+
"user": os.getenv("DB_USER", "frontend_user"),
|
10
|
+
"password": os.getenv("DB_PASSWORD", "hockey-blast"),
|
11
|
+
"host": os.getenv("DB_HOST", "localhost"),
|
12
|
+
"port": int(os.getenv("DB_PORT", 5432))
|
13
|
+
},
|
14
|
+
|
15
|
+
"frontend-sample-db": {
|
16
|
+
"dbname": os.getenv("DB_NAME_SAMPLE", "hockey_blast_sample"),
|
17
|
+
"user": os.getenv("DB_USER_SAMPLE", "frontend_user"),
|
18
|
+
"password": os.getenv("DB_PASSWORD_SAMPLE", "hockey-blast"),
|
19
|
+
"host": os.getenv("DB_HOST_SAMPLE", "localhost"),
|
20
|
+
"port": int(os.getenv("DB_PORT_SAMPLE", 5432))
|
21
|
+
},
|
22
|
+
|
23
|
+
# TODO - the section below is just to handle recovery of sample DB where boss user is present
|
24
|
+
# Maybe figure out a way to do backup without it and make frontend_user own the sample?
|
25
|
+
"boss": {
|
26
|
+
"dbname": os.getenv("DB_NAME_BOSS", "hockey_blast"),
|
27
|
+
"user": os.getenv("DB_USER_BOSS", "boss"),
|
28
|
+
"password": os.getenv("DB_PASSWORD_BOSS", "boss"),
|
29
|
+
"host": os.getenv("DB_HOST_BOSS", "localhost"),
|
30
|
+
"port": int(os.getenv("DB_PORT_BOSS", 5432))
|
31
|
+
},
|
32
|
+
}
|
33
|
+
|
34
|
+
def get_db_params(config_name):
|
35
|
+
if config_name not in DB_PARAMS:
|
36
|
+
raise ValueError(f"Invalid organization: {config_name}")
|
37
|
+
return DB_PARAMS[config_name]
|
38
|
+
|
39
|
+
def create_session(config_name):
|
40
|
+
db_params = get_db_params(config_name)
|
41
|
+
db_url = f"postgresql://{db_params['user']}:{db_params['password']}@{db_params['host']}:{db_params['port']}/{db_params['dbname']}"
|
42
|
+
engine = create_engine(db_url)
|
43
|
+
Session = sessionmaker(bind=engine)
|
44
|
+
return Session()
|
{hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/utils.py
RENAMED
@@ -82,8 +82,8 @@ def get_fake_human_for_stats(session):
|
|
82
82
|
|
83
83
|
return human.id
|
84
84
|
|
85
|
-
#
|
85
|
+
#TEST DB CONNECTION, PERMISSIONS...
|
86
86
|
# from hockey_blast_common_lib.db_connection import create_session
|
87
|
-
# session = create_session("
|
87
|
+
# session = create_session("frontend")
|
88
88
|
# human_id = get_fake_human_for_stats(session)
|
89
89
|
# print(f"Human ID: {human_id}")
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='hockey-blast-common-lib', # The name of your package
|
5
|
-
version='0.1.
|
5
|
+
version='0.1.20',
|
6
6
|
description='Common library for shared functionality and DB models',
|
7
7
|
author='Pavel Kletskov',
|
8
8
|
author_email='kletskov@gmail.com',
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# import psycopg2
|
2
|
-
from sqlalchemy import create_engine
|
3
|
-
from sqlalchemy.orm import sessionmaker
|
4
|
-
|
5
|
-
# Database connection parameters per organization
|
6
|
-
DB_PARAMS = {
|
7
|
-
"frontend": {
|
8
|
-
"dbname": "hockey_blast",
|
9
|
-
"user": "frontend_user",
|
10
|
-
"password": "hockey-blast",
|
11
|
-
"host": "localhost",
|
12
|
-
"port": 5432
|
13
|
-
},
|
14
|
-
|
15
|
-
"frontend-sample-db": {
|
16
|
-
"dbname": "hockey_blast_sample",
|
17
|
-
"user": "frontend_user",
|
18
|
-
"password": "hockey-blast",
|
19
|
-
"host": "localhost",
|
20
|
-
"port": 5432
|
21
|
-
},
|
22
|
-
|
23
|
-
"boss": {
|
24
|
-
"dbname": "hockey_blast",
|
25
|
-
"user": "boss",
|
26
|
-
"password": "WrongPassword",
|
27
|
-
"host": "localhost",
|
28
|
-
"port": 5432
|
29
|
-
},
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
def get_db_params(config_name):
|
34
|
-
if config_name not in DB_PARAMS:
|
35
|
-
raise ValueError(f"Invalid organization: {config_name}")
|
36
|
-
return DB_PARAMS[config_name]
|
37
|
-
|
38
|
-
def create_session(config_name):
|
39
|
-
db_params = get_db_params(config_name)
|
40
|
-
db_url = f"postgresql://{db_params['user']}:{db_params['password']}@{db_params['host']}:{db_params['port']}/{db_params['dbname']}"
|
41
|
-
engine = create_engine(db_url)
|
42
|
-
Session = sessionmaker(bind=engine)
|
43
|
-
return Session()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/models.py
RENAMED
File without changes
|
{hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/options.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/wsgi.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|