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.
Files changed (25) hide show
  1. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/PKG-INFO +1 -1
  2. hockey_blast_common_lib-0.1.20/hockey_blast_common_lib/db_connection.py +44 -0
  3. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/utils.py +2 -2
  4. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
  5. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/setup.py +1 -1
  6. hockey_blast_common_lib-0.1.18/hockey_blast_common_lib/db_connection.py +0 -43
  7. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/MANIFEST.in +0 -0
  8. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/README.md +0 -0
  9. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/__init__.py +0 -0
  10. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
  11. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_human_stats.py +0 -0
  12. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
  13. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
  14. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
  15. {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
  16. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/models.py +0 -0
  17. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/options.py +0 -0
  18. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
  19. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/stats_models.py +0 -0
  20. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib/wsgi.py +0 -0
  21. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
  22. {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
  23. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
  24. {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
  25. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.20}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -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()
@@ -82,8 +82,8 @@ def get_fake_human_for_stats(session):
82
82
 
83
83
  return human.id
84
84
 
85
- # TEST DB CONNECTION, PERMISSIONS...
85
+ #TEST DB CONNECTION, PERMISSIONS...
86
86
  # from hockey_blast_common_lib.db_connection import create_session
87
- # session = create_session("hockey-blast-radonly")
87
+ # session = create_session("frontend")
88
88
  # human_id = get_fake_human_for_stats(session)
89
89
  # print(f"Human ID: {human_id}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -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.18',
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()