質問編集履歴

2

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

2016/06/07 03:19

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,69 @@
19
19
  postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
20
20
 
21
21
  どこに問題があるのでしょうか?
22
+
23
+
24
+
25
+ test105.pyで保存したコードは
26
+
27
+ import psycopg2
28
+
29
+
30
+
31
+ if __name__ == "__main__":
32
+
33
+
34
+
35
+ connector = psycopg2.connect(host="localhost",database="pdb",user="pgusr",password="pgpsw")
36
+
37
+ cursor = connector.cursor()
38
+
39
+
40
+
41
+ sql = "insert into test_table values('1','python')"
42
+
43
+ cursor.execute(sql)
44
+
45
+ sql = "insert into test_table values('2','パイソン')"
46
+
47
+ cursor.execute(sql)
48
+
49
+ sql = "insert into test_table values('3','ぱいそん')"
50
+
51
+ cursor.execute(sql)
52
+
53
+
54
+
55
+ connector.commit()
56
+
57
+
58
+
59
+ cursor.close()
60
+
61
+ connector.close()
62
+
63
+
64
+
65
+ エラーメッセージは
66
+
67
+ Traceback (most recent call last):
68
+
69
+ File "test105.py", line 7, in <module>
70
+
71
+ connector = psycopg2.connect(host="localhost",database="pdb",user="pgusr",password="pgpsw")
72
+
73
+ File "C:\Python27\lib\site-packages\psycopg2\init.py", line 164, in connect
74
+
75
+ conn = _connect(dsn, connection_factory=connection_factory, async=async)
76
+
77
+ psycopg2.OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
78
+
79
+ Is the server running on host "localhost" (::1) and accepting
80
+
81
+ TCP/IP connections on port 5432?
82
+
83
+ could not connect to server: Connection refused (0x0000274D/10061)
84
+
85
+ Is the server running on host "localhost" (127.0.0.1) and accepting
86
+
87
+ TCP/IP connections on port 5432?

1

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

2016/06/07 03:19

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

test CHANGED
File without changes
test CHANGED
@@ -19,25 +19,3 @@
19
19
  postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
20
20
 
21
21
  どこに問題があるのでしょうか?
22
-
23
- 使用しているOS: Windows 10
24
-
25
- 使用しているPCのメーカー/NECLL550/k
26
-
27
- 関係するアプリケーション名/Python2.7.11
28
-
29
- 関係する機器の機種名/型番:postgresql-9.6.0-beta1-windows-x64.exe
30
-
31
- エラーメッセージなど(原文のまま):psycopg2-2.6.1.win32-py2.7-pg9.4.4-release.exeからダウンロードインストールをいたしました。
32
-
33
-
34
-
35
- この状況の中Pythonからpsycopg2をインポートしようとするとエラーになります。別の形で質問しましたがタイトルを変えて質問したほうが良いとのことでしたので改めて質問させていただきます。
36
-
37
- 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のパスワード認証は認証なしに設定しました。
38
-
39
-
40
-
41
- postgresql-9.6はPATHはc:¥program Files¥PostgreSQL¥9.6¥binとなっています。
42
-
43
- どこに問題があるのでしょうか?