hockey-blast-common-lib 0.1.18__tar.gz → 0.1.19__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.19}/PKG-INFO +1 -1
  2. hockey_blast_common_lib-0.1.19/hockey_blast_common_lib/db_connection.py +42 -0
  3. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
  4. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/setup.py +1 -1
  5. hockey_blast_common_lib-0.1.18/hockey_blast_common_lib/db_connection.py +0 -43
  6. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/MANIFEST.in +0 -0
  7. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/README.md +0 -0
  8. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/__init__.py +0 -0
  9. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
  10. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/aggregate_human_stats.py +0 -0
  11. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
  12. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
  13. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
  14. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  15. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/models.py +0 -0
  16. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/options.py +0 -0
  17. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
  18. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/stats_models.py +0 -0
  19. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/utils.py +0 -0
  20. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib/wsgi.py +0 -0
  21. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
  22. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/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.19}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
  24. {hockey_blast_common_lib-0.1.18 → hockey_blast_common_lib-0.1.19}/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.19}/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.19
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,42 @@
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
+ "boss": {
24
+ "dbname": os.getenv("DB_NAME_BOSS", "hockey_blast"),
25
+ "user": os.getenv("DB_USER_BOSS", "boss"),
26
+ "password": os.getenv("DB_PASSWORD_BOSS", "WrongPassword"),
27
+ "host": os.getenv("DB_HOST_BOSS", "localhost"),
28
+ "port": int(os.getenv("DB_PORT_BOSS", 5432))
29
+ },
30
+ }
31
+
32
+ def get_db_params(config_name):
33
+ if config_name not in DB_PARAMS:
34
+ raise ValueError(f"Invalid organization: {config_name}")
35
+ return DB_PARAMS[config_name]
36
+
37
+ def create_session(config_name):
38
+ db_params = get_db_params(config_name)
39
+ db_url = f"postgresql://{db_params['user']}:{db_params['password']}@{db_params['host']}:{db_params['port']}/{db_params['dbname']}"
40
+ engine = create_engine(db_url)
41
+ Session = sessionmaker(bind=engine)
42
+ return Session()
@@ -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.19
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.19',
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()