Created
August 26, 2018 09:52
-
-
Save ademola25/4ed0ea71765763d6ef5012fa5dbb832b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Install the Python PostgreSQL adapter psycopg: sudo apt-get install python-psycopg2 | |
| Install PostgreSQL: sudo apt-get install postgresql postgresql-contrib | |
| To check, no remote connections are allowed : sudo vim /etc/postgresql/9.3/main/pg_hba.conf | |
| open database_setup.py using : sudo nano database_setup.py | |
| update the create_engine line: python engine = create_engine('postgresql://catalog:catalog-pw@localhost/catalog') | |
| Update the create_engine line in project.py and lotsofmenus.py too. | |
| move the project.py file to init.py file : mv application.py init.py | |
| Change to default user postgres: sudo su - postgre | |
| Connect to the system: psql | |
| Create user catalog: CREATE USER catalog WITH PASSWORD 'catalog-pw'; | |
| check lists of roles using\du | |
| Allow the user to create database : ALTER USER catalog CREATEDB; and check the roles and attributes using \du. | |
| Create database using : CREATE DATABASE catalog WITH OWNER catalog; | |
| Connect to database using : \c catalog | |
| Revoke all the rights : REVOKE ALL ON SCHEMA public FROM public; | |
| Grant the access to catalog: GRANT ALL ON SCHEMA public TO catalog; | |
| Once you execute database_setup.py , again you can login as psql and check all the tables with following commands: | |
| connect to database using : \c catalog | |
| To see the tables in schema :\dt | |
| to see particular table:\d [tablename] | |
| to see the entries/data in table :select * from [tablename]; | |
| to drop the table:drop table [tablename]; | |
| exit from Postgresql : \qthen exitfrom postgresql user. | |
| restart postgresql: sudo service postgresql restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment