jasonleonhard / gyfted

Gyfted (pronounced gift-ed) Like Lyft for improving peoples lives that need it most
1 stars 1 forks source link

Launching postgres in Mac and Windows #22

Open williamsmichael opened 7 years ago

williamsmichael commented 7 years ago

CREATE VIRTUAL ENVIRONMENT

PIPENV workaround

  1. Create an empty Python3 virtual environment named "gyfted"

    • virtualenv virtualenv -p python3 gyfted source
    • virtualenvwrapper mkvirtualenv -p python3 gyfted source
    • mini conda conda create -n gyfted python=3 source
  2. Install project requirements pip install -r requirements.txt


POSTGRESQL

MAC

  1. Download postgresapp
  2. Follow the instructions steps 1-2
  3. Attempt step 3 for the command line option. Quit terminal.
  4. Launch terminal. Test if it works with which psql and it should return /Applications/Postgres.app/Contents/Versions/latest/bin/psql. Another test is run psql and it should return [database name]=#
  5. If the psql environment does not launch:
    • Check if a .bash_profile exists open -a TextEdit ~/.bash_profile. This article explains why the postgresapp documentation sudo command did not work because a .bash_profile exists.
      • If the .bash_profile exists, you have the option to create a .profile or add the following to the end of the .bash_profile from this article export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
  6. Run step 4 again to test

WINDOWS

  1. Tutorial, still needs vetted source

CREATE DATABASE

  1. Launch postgres app for Mac or Windows
  2. Run export DATABASE_URL='postgresql://localhost/gyfted_dev'
  3. Test the database exists, run env | grep -i dat and it should return DATABASE_URL='postgresql://localhost/gyfted_dev'
  4. Run psql -a -f postgresql_setup.sql
  5. Run python db_create.py and it should return []
  6. Run python app.py
  7. Open in browser http://127.0.0.1:5000/ #
williamsmichael commented 7 years ago

@jasonleonhard here are the steps without pipenv and make. For me, the make command works as long as there is not a pipenv in the command. I attempted to install pipenv but received an error that I could not make sense of and decided to move past it, at this time. The pipenv and MakeFile are great but either need to be refactored for easy install or allow for the user to create a virtualenv of choice, load the requirements, and run make commands without pipenv.

@91ashika provided a link for installing postgresql for windows. Have not had a chance to test. The biggest hurdle from the mac side included getting the psql to run in the command line. From there, everything else fell into place.

bonniekbright commented 7 years ago

I followed this step to get psql running in terminal, ran both of these and now it works in terminal. PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH" export PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH"

When I tried to run psql -a -f postgresql_setup.sql python3 db_create.py it wouldn't work with the env so I changed line 9 in models.py to app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/gyfted_dev' and now project is running.

91ashika commented 7 years ago

I have postgres installed already.For some reason, my system is hanging at this command 'psql -a -f postgresql_setup.sql'. I will try to figure it out. If nothing works by tomorrow, I will setup mysql locally and try to use it.

williamsmichael commented 6 years ago

@91ashika, if you could when time permits update the Windows section in the original portion of the request postgres steps or open a new issue to post the steps for mySQL for windows, that would be helpful.