LoginSignup
6
5

More than 5 years have passed since last update.

python3でPostgreSQLに接続する

Posted at

psycopq2を使用して接続する

psyopq2をダウンロード

公式サイト:http://initd.org/psycopg/download/

↑にある通り、pipを使う

pip install -U pip # pip自体を最新のもの
pip install psycopg2

python3からの接続

>>> import psycopq2
>>> connection = psycopg2.connect(host="localhost", database="<データベース名>", user="<ユーザー名>",password="<パスワード>")

何もエラーが出なければ接続OK

6
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5