Skip to content

ZealousProgramming/swapi-to-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swapi-to-postgresql

A utility script to import data from Star Wars API to a local postgreSQL database Showcase Image

Pre-Requisites

  • Python 3.8+
  • PostgreSQL driver

Installation

  • 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.

Usage

  • DATABASE: Set the name of the database via the -db or --database flags
  • PORT_ID: Set the port to connect to via the -p or --port flags
  • USERNAME: An environment variable of the username you use for postgreSQL (DEFAULT: BOOTCAMP_USER)
    • To use a different username, use the user flag (-u, --user)
  • 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)
  • 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
  • -h, --host: The host to connect to
    • DEFAULT: localhost
    • To change: -h="localhost" or --host="localhost"
  • -u, --user: The postgres user
    • DEFAULT: BOOTCAMP_USER(Environment Variable)
    • To change: -u="some-user" or --user="other-user"
  • -pw, --password: The password to the postgres user
    • DEFAULT: BOOTCAMP_CREDS(Environment Variable)
    • To change: -pw="$0m3P@$$w0rd" or --password="$0m3P@$$w0rd"
  • -p, --port: The port to connect to
    • DEFAULT: 5432
    • To change: -p=5433 or --port=5433
  • -d, --data: Use a modified version of the dataset
    • To change: -d="./bin/some_data.json" or --data="./bin/some_custom_data.json"
  • -c, --cache: Set whether to take advantage of caching
    • DEFAULT: True
    • To disable: -c=false or --cache=false
  • -f, --force: Forces a refetch to update the cache
    • DEFAULT: False
    • To enable: -f or --force
  • -fmt, --format: Set whether it should run the consistency formatter
    • DEFAULT: True
    • To disable: -fmt=false or --format=false
  • -v, --verbose: Produce and display a detailed output of the process
    • DEFAULT: False
    • To enable: -v or --verbose
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

Future Features

  • 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

About

A utility script to import data from Star Wars API to a local postgreSQL database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages