Setting Up Database Servers for Development on Mac OS X Using Docker. Download and run PostgreSQL. Go to the Oracle Database image page on Docker Store. Postico provides an easy to use interface, making Postgres more accessible for newcomers and specialists alike. Postico will look familiar to anyone who has used a Mac before. Just connect to a database and begin working with tables and views. How do I find PostgreSQL's data directory? Ask Question. Browse other questions tagged postgresql mac-os-x or ask your own question. 7 years, 10 months ago. 1 year, 2 months ago. Blog Adios to Winter Bash 2018. Create database on new partition. PostgreSQL 9.1 Hot Backup Error: the database system is starting.
I upgraded my Mac to OS X Sierra from OS X Yosemite. Since doing this, a piece of software I use (Da Vinci Resolve) no longer shows my database of projects. Da Vinci Resolve support say this about the problem:
'The issue is that PostgreSQL does not work in Sierra. You would need to go back to El Capitan or earlier, and then restore your database.'
I have since installed another hard drive and installed the older OS X Yosemite on it. I now require PostgreSQL to be configured so that my old database shows in Da Vinci Resolve.
I have a backup of the 'data' folder from my PostgreSQL database (26.6GB in size).
I will provide access via remote desktop.
This blog post is about creating a simple pre-registration page using the best (in my opinion) micro web-development framework for Python, Flask. We will be connecting our pre-registation app to a PostgreSQL database locally and in the cloud. Once we have our Flask app running locally, I will show you how to successfully deploy it to Heroku.
Notes:
Let’s get started.
1.)
Installation and environment setup
We will need to install the following:
First, install pip by running the command Free software for mac.
in your terminal.
Then, install virtualenv by running the command
Now, we can create our project directory and set up our virtual environment.
To set up a virtual environment
You should now have a venv
folder within your lovelypreregpage
project.
To start your virtual environment run the command
Next, we can begin setting up our database. Go to postgresapp.com and download/install postgres.app
just like any other application. Postgres.app
is super easy to set up, but don’t forget to add the following to your .bash_profile
found in your home directory
All we have to do now is launch Postgres.app
(found in applications) and hit Open psql
. In your bash
terminal, create a new database by running the command
Now, open up the postgres terminal launched when hitting Open psql
and run the command
You should see the database pre-registration
listed in the table.
2.)
Setting up our actual Flask app
First, create the following files and folders
Open up your .gitignore
file and add the following
Now, go into your static
folder and add following two folders and their respective files
css
–> bootstrap.min.css, styles.css (found here)js
–> bootstrap.min.js, scripts.js (found here)Then, go into your templates
folder and add the following two HTML files
index.html
found heresuccess.html
found hereA couple things to notice in the HTML files; links to static files in Flask are done a special way, and calling a method from a form action is done similarly.
Let’s install some Flask stuff now. Run the following commands in your terminal
Next, we have to write the python code to do things and connect our database. Add the following code to your app.py
file
To create our database based off our model, run the following commands
Now, run python app.py
in your terminal. You should see * Running on http://127.0.0.1:5000/
, go to http://127.0.0.1:5000/ and experience beauty.
*Bonus, a great postgres GUI client for Mac OS X is Induction
. Just go here to download and install. Launch the app and enter postgres://localhost/pre-registration
as your database URL. Next, browse your data. :)
3.)
Deploy to Heroku
First, go to Heroku and install the Heroku toolbelt just like any other application. While you are at it, create an account on Heroku if you do not have one already. Make sure to add your ssh key(s). Then, before you can create a Heroku app from your existing project we need to turn it into a git repo. Go here to install git on your machine.
Let’s go ahead and create a couple more files we will need for deploying to Heroku
Now, run the following to commands with your virtual environment running
That last command is putting all our app requirements into requirements.txt
so Heroku knows what it needs to install.
Add the following line to your Procfile
which tells heroku what python file to execute
Open up your `app.py file and edit your imports and database connections to look like this
Since we have Heroku and git installed, run the following commands while in your lovelypreregpage
project
The last command will automatically create a Heroku app using the name you give. Next, run the following command to push your Flask app up to Heroku
Setting up a PostgreSQL database on Heroku is a lot like setting up a PostgreSQL database locally. Run the following commands
*It is important to switch HEROKU_POSTGRESQL_COLOR_URL
with the color shown to you after running the heroku addons:add heroku-postgresql:dev
command.
Now, run the following commands to create our database tables exactly as we did before
Finally, go to name-of-your-app.herokuapp.com
and see your working pre-registration page! It is not the sexiest website, but now that you know how to make it you can spend time on front-end shenanigans.
To see the live demo of this tutorial go to flask-postgres-heroku.herokuapp.com.
*Bonus, Heroku allows you to create Dataclips, which is similar to Induction
. Create a Dataclip
and run the query
to see all the users that have pre-registered for your awesome app.