hockey-blast-common-lib 0.1.16__py3-none-any.whl → 0.1.17__py3-none-any.whl

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.
@@ -0,0 +1,24 @@
1
+ #!/bin/zsh
2
+
3
+ # Database credentials from environment variables
4
+ DB_USER=${DB_USER:-"frontend_user"}
5
+ DB_PASSWORD=${DB_PASSWORD:-"hockey-blast"}
6
+ DB_NAME=${DB_NAME:-"hockey_blast_sample"}
7
+ DB_HOST=${DB_HOST:-"localhost"}
8
+ DB_PORT=${DB_PORT:-"5432"}
9
+ DUMP_FILE="hockey_blast_sample_backup.sql"
10
+ COMPRESSED_DUMP_FILE="hockey_blast_sample_backup.sql.gz"
11
+
12
+ # Export PGPASSWORD to avoid password prompt
13
+ export PGPASSWORD=$DB_PASSWORD
14
+
15
+ # Dump the database schema and data
16
+ pg_dump --username=$DB_USER --host=$DB_HOST --port=$DB_PORT --format=custom --file=$DUMP_FILE $DB_NAME
17
+
18
+ # Compress the backup file
19
+ gzip -c $DUMP_FILE > $COMPRESSED_DUMP_FILE
20
+
21
+ # Remove the uncompressed backup file
22
+ rm $DUMP_FILE
23
+
24
+ echo "Database dump completed: $COMPRESSED_DUMP_FILE"
@@ -0,0 +1,34 @@
1
+ #!/bin/zsh
2
+
3
+ # Database credentials from environment variables
4
+ DB_USER=${DB_USER:-"frontend_user"}
5
+ DB_PASSWORD=${DB_PASSWORD:-"hockey-blast"}
6
+ DB_NAME=${DB_NAME:-"hockey_blast_sample"}
7
+ DB_HOST=${DB_HOST:-"localhost"}
8
+ DB_PORT=${DB_PORT:-"5432"}
9
+ COMPRESSED_DUMP_FILE="hockey_blast_sample_backup.sql.gz"
10
+
11
+ # Superuser credentials
12
+ SUPERUSER="your_superuser"
13
+ SUPERUSER_PASSWORD="your_superuser_password"
14
+
15
+ # Export PGPASSWORD to avoid password prompt
16
+ export PGPASSWORD=$SUPERUSER_PASSWORD
17
+
18
+ # Drop the existing database if it exists
19
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --command="SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB_NAME' AND pid <> pg_backend_pid();"
20
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --command="DROP DATABASE IF EXISTS $DB_NAME"
21
+
22
+ # Create a new database
23
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --command="CREATE DATABASE $DB_NAME OWNER $SUPERUSER"
24
+
25
+ # Export PGPASSWORD for read-only user
26
+ export PGPASSWORD=$DB_PASSWORD
27
+
28
+ # Restore the database from the dump file with --no-owner option
29
+ gunzip -c $COMPRESSED_DUMP_FILE | pg_restore --username=$DB_USER --host=$DB_HOST --port=$DB_PORT --dbname=$DB_NAME --format=custom --no-owner
30
+
31
+ # Grant necessary permissions to the read-only user
32
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT --dbname=$DB_NAME --command="GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO frontend_user"
33
+
34
+ echo "Database restore completed: $DB_NAME"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -4,12 +4,15 @@ hockey_blast_common_lib/aggregate_human_stats.py,sha256=88OMhTgQjzc9xIakf6kW9_lZ
4
4
  hockey_blast_common_lib/aggregate_referee_stats.py,sha256=A0PTyEbPUjqfXxlJCDOVioFaQk9AyjjhiWEuRuu35v0,11036
5
5
  hockey_blast_common_lib/aggregate_skater_stats.py,sha256=37fhgej9trukr8cGaK7DT1HoxBcp95qwsypYCCziqqc,15563
6
6
  hockey_blast_common_lib/db_connection.py,sha256=8XWa4R0tBR1bCe1gZeBCOkvIrM25lzEUxtn1HGTsyX4,1181
7
+ hockey_blast_common_lib/dump_sample_db.sh,sha256=MHPA-Ciod7wsvAlMbRtXFiyajgnEqU1xR59sJQ9UWR0,738
8
+ hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=JIk9FeWrEqHvmTLeueJtSkK2mNpg_xtonAMHDKlYe-4,1033693
7
9
  hockey_blast_common_lib/models.py,sha256=GqQIGpanmFub97BoYCuaqDov2MxM4LMesUTxZ2edpvw,15393
8
10
  hockey_blast_common_lib/options.py,sha256=-LtEX8duw5Pl3CSpjFlLM5FPvrZuTAxTfSlDPa7H6mQ,761
11
+ hockey_blast_common_lib/restore_sample_db.sh,sha256=rILfnODJ6S0-D2acNv0pjtUXU76O1lEd4Tn6Y9QSGFE,1517
9
12
  hockey_blast_common_lib/stats_models.py,sha256=PI-mL1jmjCHLAvaATxSsjHEn05g9L_reA_YpsITPWjQ,21047
10
13
  hockey_blast_common_lib/utils.py,sha256=OmeLVJSsjoBrE---w9MwXPKD3-UMZ9HB6a4YtsGDj30,3765
11
14
  hockey_blast_common_lib/wsgi.py,sha256=wl1gf3KtaGSnYbCF5Z2xWwRXNSTQp43HoyhCAKJibI4,750
12
- hockey_blast_common_lib-0.1.16.dist-info/METADATA,sha256=oEVUVZiu6v9n4U83MYtlVEgB9fQMy49ItPfeIHAQTc0,318
13
- hockey_blast_common_lib-0.1.16.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
- hockey_blast_common_lib-0.1.16.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
15
- hockey_blast_common_lib-0.1.16.dist-info/RECORD,,
15
+ hockey_blast_common_lib-0.1.17.dist-info/METADATA,sha256=nvrB8rZrlne5zvJtn540pvhaMGJYoY9Zp5eoPid0BP8,318
16
+ hockey_blast_common_lib-0.1.17.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
+ hockey_blast_common_lib-0.1.17.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
18
+ hockey_blast_common_lib-0.1.17.dist-info/RECORD,,