Files
basegame-vcko/sql/INSTALL_PROCEDURES.md

2.8 KiB

Installing Stored Procedures

All stored procedure SQL files are ready to use. You have several options:

Prerequisites

  1. SSH Port Forwarding - Make sure you have an active SSH tunnel:

    ssh -L 3306:localhost:3306 lukesau.com
    

    Keep this terminal open while running SQL commands.

  2. MySQL Client - Install if needed:

    brew install mysql-client
    

    To add mysql-client to your PATH permanently, add to ~/.zshrc:

    echo 'export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    

Option 1: Use the Helper Script (Easiest)

./sql/run_sql.sh sql/create_all_stored_procedures.sql

Option 2: Use MySQL Client Directly

If mysql is in your PATH (added to ~/.zshrc), you can use:

mysql -h 127.0.0.1 -P 3306 -u vckonline -p vckonline < sql/create_all_stored_procedures.sql

Or use the full path:

/opt/homebrew/opt/mysql-client/bin/mysql -h 127.0.0.1 -P 3306 -u vckonline -p vckonline < sql/create_all_stored_procedures.sql

Note: The -h 127.0.0.1 -P 3306 flags connect through your SSH tunnel to the remote database.

Option 3: Interactive MariaDB Session

If you're already logged into MariaDB on the server:

source sql/create_all_stored_procedures.sql;

Option 4: Install Individually

Run each procedure file separately using the helper script:

./sql/run_sql.sh sql/select_base1_citizens_sp.sql
./sql/run_sql.sh sql/select_base1_monsters_sp.sql
./sql/run_sql.sh sql/select_base2_citizens_sp.sql
./sql/run_sql.sh sql/select_base2_monsters_sp.sql
./sql/run_sql.sh sql/select_random_domains_sp.sql
./sql/run_sql.sh sql/select_random_dukes_sp.sql

Or using mysql client directly:

/opt/homebrew/Cellar/mysql-client/9.5.0/bin/mysql -h 127.0.0.1 -P 3306 -u vckonline -p vckonline < sql/select_base1_citizens_sp.sql
# ... repeat for each file

Or interactively in MariaDB on the server:

source sql/select_base1_citizens_sp.sql;
source sql/select_base1_monsters_sp.sql;
source sql/select_base2_citizens_sp.sql;
source sql/select_base2_monsters_sp.sql;
source sql/select_random_domains_sp.sql;
source sql/select_random_dukes_sp.sql;

Verify Installation

After installing, verify with:

SHOW PROCEDURE STATUS WHERE Db = 'vckonline';

Or run the test script:

python3 test_database.py

What Each Procedure Does

  • select_base1_citizens() - Returns all citizens from base game 1
  • select_base1_monsters() - Returns all monsters from base game 1
  • select_base2_citizens() - Returns base game 2 citizens + Peasant and Knight from base1
  • select_base2_monsters() - Returns base game 2 monsters + 2 random areas from base1
  • select_random_domains() - Returns 15 random domains
  • select_random_dukes() - Returns all dukes in random order