Chron script for loading database
This commit is contained in:
16
loader/chron-script.sh
Normal file
16
loader/chron-script.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
|
||||
|
||||
PYTHON_VEN="$parent_path"/venv/bin/python
|
||||
if [ ! -f $PYTHON_VEN ]; then
|
||||
echo "Setting up new VENV"
|
||||
python -m venv venv
|
||||
echo "Installing requirements."
|
||||
source ./venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
deactivate
|
||||
fi
|
||||
|
||||
echo "Start DB Creation"
|
||||
$parent_path/venv/bin/python createrushdatabase.py
|
||||
@@ -12,6 +12,10 @@ Game = namedtuple('Game',
|
||||
|
||||
Link = namedtuple('Link', ['gameId', 'gameTitle', 'characterId', 'characterName'])
|
||||
|
||||
SET_WAL_PRAGMA = """
|
||||
PRAGMA journal_mode=WAL;
|
||||
"""
|
||||
|
||||
APPS_TABLE_CREATE = """
|
||||
CREATE TABLE IF NOT EXISTS "Apps" (
|
||||
"gameId" INTEGER,
|
||||
@@ -170,6 +174,7 @@ def loadAppsAndPicks(characterNameToId, gameTitleToId, gameFileName):
|
||||
def createTables(dbName):
|
||||
with sqlite3.connect(dbName) as connection:
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(SET_WAL_PRAGMA)
|
||||
cursor.execute(CHARACTER_TABLE_CREATE)
|
||||
cursor.execute(GAMES_TABLE_CREATE)
|
||||
cursor.execute(APPS_TABLE_CREATE)
|
||||
|
||||
5
loader/requirements.txt
Normal file
5
loader/requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
certifi==2024.6.2
|
||||
charset-normalizer==3.3.2
|
||||
idna==3.7
|
||||
requests==2.32.3
|
||||
urllib3==2.2.1
|
||||
Reference in New Issue
Block a user