A utility script to import data from Star Wars API to a local postgreSQL database
- Python 3.8+
- PostgreSQL driver
- SSH
git clone git@github.com:ZealousProgramming/swapi-to-postgresql.git
- HTTP
git clone https://github.com/ZealousProgramming/swapi-to-postgresql.git
- Add
BOOTCAMP_USER
to your environment variables. The value will be your postgreSQL username (DEFAULT:postgres
) - Add
BOOTCAMP_CREDS
to your environment variables. The value will be your postgreSQL user password. - Restart your terminal, if it is running.
DATABASE
: Set the name of the database via the-db
or--database
flagsPORT_ID
: Set the port to connect to via the-p
or--port
flagsUSERNAME
: An environment variable of the username you use for postgreSQL (DEFAULT:BOOTCAMP_USER
)- To use a different username, use the user flag (
-u, --user
)
- To use a different username, use the user flag (
PWD
: An environment variable of the password you use for postgreSQL (DEFAULT:BOOTCAMP_CREDS
)- To use a different password, use the pw flag (
-pw, --password
)
- To use a different password, use the pw flag (
HOST
: Set the host to connect to via the-h
or--host
flags
Options:
-db, --database
: Name of the database to connect to- DEFAULT:
bootcamp
- To change:
-db=some_db
or--database=some_other_db
- DEFAULT:
-h, --host
: The host to connect to- DEFAULT:
localhost
- To change:
-h="localhost"
or--host="localhost"
- DEFAULT:
-u, --user
: The postgres user- DEFAULT:
BOOTCAMP_USER(Environment Variable)
- To change:
-u="some-user"
or--user="other-user"
- DEFAULT:
-pw, --password
: The password to the postgres user- DEFAULT:
BOOTCAMP_CREDS(Environment Variable)
- To change:
-pw="$0m3P@$$w0rd"
or--password="$0m3P@$$w0rd"
- DEFAULT:
-p, --port
: The port to connect to- DEFAULT:
5432
- To change:
-p=5433
or--port=5433
- DEFAULT:
-d, --data
: Use a modified version of the dataset- To change:
-d="./bin/some_data.json"
or--data="./bin/some_custom_data.json"
- To change:
-c, --cache
: Set whether to take advantage of caching- DEFAULT:
True
- To disable:
-c=false
or--cache=false
- DEFAULT:
-f, --force
: Forces a refetch to update the cache- DEFAULT:
False
- To enable:
-f
or--force
- DEFAULT:
-fmt, --format
: Set whether it should run the consistency formatter- DEFAULT:
True
- To disable:
-fmt=false
or--format=false
- DEFAULT:
-v, --verbose
: Produce and display a detailed output of the process- DEFAULT:
False
- To enable:
-v
or--verbose
- DEFAULT:
cd swapi-to-postgresql
# In the repo source directory
python ./script.py
python ./script.py -db=some_database # Connect to a db other than `bootcamp`
python ./script.py -p=5433 # Connect to a db on a port other than `5432`
python ./script.py -c=false # Turn off the use of caching
python ./script.py -d="./bin/custom_data.json" # Use a modified version of the dataset
python ./script.py -f # Force a cache update
python ./script.py -v # Produce a detailed output
python ./script.py --cache=false
python ./script.py --force
python ./script.py --format=false # Disable consistency formatting
python ./script.py -c=false -v -fmt=false
python ./script.py -c=false --verbose
python ./script.py --cache=false --verbose
- Import all tables
- Format flag
- Syntax error messages for flag setting
- Update documentation to reflect the refactor
- Flag to use another dbname
- Flag to use another port
- Connection error message
- Allow for a custom data