자주 까먹는 명령어
사용자 생성
create role <username> with login password <password>;
권한 지정
grant usage on schema public to <username>;
grant all on schema public to <username>;
grant all privileges on database <dbname> to <username>;
grant all on all tables in schema public to <username>
grant select on <table> to <username>;
읽기 전용 계정 만들기 http://stackoverflow.com/questions/760210/how-do-you-create-a-read-only-user-in-postgresql
GRANT CONNECT ON DATABASE mydb TO xxx;
GRANT USAGE ONSCHEMApublic TO xxx;
GRANT SELECT ON mytable TO xxx;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx;
커넥션 현황 보기
SELECT count(*) from pg_stat_activity;
파이썬에서 사용하기
import psycopg2
conn = psycopg2.connect('host=db.com user=youngrok password=blahblah dbname=mydb
cursor = conn.cursor()
cursor.execute('SELECT * FROM auth_user')
print cursor.fetchall()