이콜레모 개발자 위키

Page history of PostgreSQL



Title: PostgreSQL | edited by Youngrok Pak at 9 years, 6 months ago.

<h2>자주 까먹는 명령어</h2>
<p>사용자 생성</p>
<pre>create role &lt;username&gt; with login password &lt;password&gt;;</pre>
<p>권한 지정</p>
<pre>grant usage on schema public to &lt;username&gt;;<br>grant all on schema public to &lt;username&gt;;<br>grant all privileges on database &lt;dbname&gt; to &lt;username&gt;;<br>grant all on all tables in schema public to &lt;username&gt;<br>grant select on &lt;table&gt; to &lt;username&gt;;</pre>
<p>커넥션 현황 보기</p>
<pre>SELECT count(*) from pg_stat_activity;</pre>
<h2>파이썬에서 사용하기</h2>
<pre>import psycopg2<br>conn = psycopg2.connect('host=db.com user=youngrok password=blahblah dbname=mydb<br>cursor = conn.cursor()<br>cursor.execute('SELECT * FROM auth_user')<br>print cursor.fetchall()</pre>
<p> 
Wiki at WikiNamu