Example project for Flask APP.
- Python: v3.6 or above
- Install required python packages:
pip install -r requirements.txt
- Migrate database schema / Create admin user:
python admin.py
- Run flask server:
python run.py
1. Install PostgreSQL
2. Login as the default user: `sudo -u postgres psql`
3. Create a database: `create database <dbname>;`
4. Create an user account: `create user <username> with encrypted password '<password>';`
5. Grant database access to the user: `grant all privileges on database <dbname> to <username>;`
(Alternative way)
1. `sudo -u postgres createuser <username>`
2. `sudo -u postgres createdb <dbname>`
3. `sudo -u postgres psql`
4. `alter user <username> with encrypted password '<password>';`
5. `grant all privileges on database <dbname> to <username> ;`
\?
list all the commands\l
list databases\conninfo
display information about current connection\c [DBNAME]
connect to new database, e.g., \c template1\dt
list tables of the public schema\dt
.* list tables of certain schema, e.g., \dt public.*\dt *.*
list tables of all schemas. Then you can run SQL statements, e.g., SELECT * FROM my_table; (Note: a statement must be terminated with semicolon ;)\q
quit psql
PostgreSQL setup: https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e