You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
723 B

  1. SQL test
  2. ===
  3. Nathan's SQL answers. Tests past in `test/test_example.py`
  4. ### Prerequisistes
  5. ```bash
  6. $ python3 -m pip install pipenv --user
  7. ```
  8. - Use virtualenv
  9. ```bash
  10. $ PIPENV_VENV_IN_PROJECT=true pipenv shell
  11. ```
  12. - Install dependencies
  13. ```bash
  14. $ pipenv install --dev
  15. ```
  16. ### Usage
  17. - Run up Postgresql server
  18. ```bash
  19. $ docker-compose up db
  20. ```
  21. - Stop Postgresql server
  22. ```bash
  23. $ docker-compose down
  24. ```
  25. - Connect to test database on Postgresql server using psql
  26. ```bash
  27. $ docker-compose exec db psql -U postgres test
  28. ```
  29. - Execute SQL file
  30. ```bash
  31. $ docker-compose exec db psql -v ON_ERROR_STOP=1 -U postgres test -a -f "sql/schema.sql"
  32. ```
  33. - Testing using database
  34. ```bash
  35. $ docker-compose up dbtest
  36. ```