質問するログイン新規登録

質問編集履歴

2

コードの記述とエラーメッセッジを記載いたしました

2016/06/07 03:19

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

title CHANGED
File without changes
body CHANGED
@@ -8,4 +8,37 @@
8
8
  postgresql-9.6はPATHも通しましてpostgresql listen_addresses='*'('localhost') log_desination='stderr'('stderr,csvlog,eventlog') log_line_prefix='%t'('%t') client_encoding=sql_ascil(sjis) pg_hba.confのパスワード認証は認証なしに設定しました。
9
9
 
10
10
  postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
11
- どこに問題があるのでしょうか?
11
+ どこに問題があるのでしょうか?
12
+
13
+ test105.pyで保存したコードは
14
+ import psycopg2
15
+
16
+ if __name__ == "__main__":
17
+
18
+ connector = psycopg2.connect(host="localhost",database="pdb",user="pgusr",password="pgpsw")
19
+ cursor = connector.cursor()
20
+
21
+ sql = "insert into test_table values('1','python')"
22
+ cursor.execute(sql)
23
+ sql = "insert into test_table values('2','パイソン')"
24
+ cursor.execute(sql)
25
+ sql = "insert into test_table values('3','ぱいそん')"
26
+ cursor.execute(sql)
27
+
28
+ connector.commit()
29
+
30
+ cursor.close()
31
+ connector.close()
32
+
33
+ エラーメッセージは
34
+ Traceback (most recent call last):
35
+ File "test105.py", line 7, in <module>
36
+ connector = psycopg2.connect(host="localhost",database="pdb",user="pgusr",password="pgpsw")
37
+ File "C:\Python27\lib\site-packages\psycopg2\init.py", line 164, in connect
38
+ conn = _connect(dsn, connection_factory=connection_factory, async=async)
39
+ psycopg2.OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
40
+ Is the server running on host "localhost" (::1) and accepting
41
+ TCP/IP connections on port 5432?
42
+ could not connect to server: Connection refused (0x0000274D/10061)
43
+ Is the server running on host "localhost" (127.0.0.1) and accepting
44
+ TCP/IP connections on port 5432?

1

すみません。重複に気が付きませんでした。修正いたしました

2016/06/07 03:19

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

title CHANGED
File without changes
body CHANGED
@@ -8,15 +8,4 @@
8
8
  postgresql-9.6はPATHも通しましてpostgresql listen_addresses='*'('localhost') log_desination='stderr'('stderr,csvlog,eventlog') log_line_prefix='%t'('%t') client_encoding=sql_ascil(sjis) pg_hba.confのパスワード認証は認証なしに設定しました。
9
9
 
10
10
  postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
11
- どこに問題があるのでしょうか?
12
- 使用しているOS: Windows 10
13
- 使用しているPCのメーカー/NECLL550/k
14
- 関係するアプリケーション名/Python2.7.11
15
- 関係する機器の機種名/型番:postgresql-9.6.0-beta1-windows-x64.exe
16
- エラーメッセージなど(原文のまま):psycopg2-2.6.1.win32-py2.7-pg9.4.4-release.exeからダウンロードインストールをいたしました。
17
-
18
- この状況の中Pythonからpsycopg2をインポートしようとするとエラーになります。別の形で質問しましたがタイトルを変えて質問したほうが良いとのことでしたので改めて質問させていただきます。
19
- postgresql-9.6はPATHも通しましてpostgresql listen_addresses='*'('localhost') log_desination='stderr'('stderr,csvlog,eventlog') log_line_prefix='%t'('%t') client_encoding=sql_ascil(sjis) pg_hba.confのパスワード認証は認証なしに設定しました。
20
-
21
- postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
22
11
  どこに問題があるのでしょうか?