質問編集履歴

2

誤字

2020/01/25 13:23

投稿

yamadataro3
yamadataro3

スコア12

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  必要な時に別クラス(別ファイル)からcursorを使用したいと考えています。
4
4
 
5
- 現状は以下のようにDbaccessクラスのgrobal変数に設定しています。
5
+ 現状は以下のようにDbaccessクラスのglobal変数に設定しています。
6
6
 
7
7
  grobal変数はあまり使用したくないのですが、
8
8
 
@@ -12,9 +12,9 @@
12
12
 
13
13
  main.py
14
14
 
15
- class test_g
15
+ class test_g():
16
16
 
17
- test = Dbaccess()
17
+ test = Dbaccess():
18
18
 
19
19
  test.db_init()
20
20
 
@@ -40,15 +40,15 @@
40
40
 
41
41
  import psycopg2
42
42
 
43
- class Dbaccess
43
+ class Dbaccess():
44
44
 
45
45
  cur = ""
46
46
 
47
47
 
48
48
 
49
- def db_init()
49
+ def db_init():
50
50
 
51
- grobal cur
51
+ global cur
52
52
 
53
53
  conn = psycopg2.connect("dbname=test user=postgres")
54
54
 
@@ -56,9 +56,9 @@
56
56
 
57
57
 
58
58
 
59
- def get_cur()
59
+ def get_cur():
60
60
 
61
- grobal cur
61
+ global cur
62
62
 
63
63
  return cur
64
64
 
@@ -76,9 +76,9 @@
76
76
 
77
77
 
78
78
 
79
- class Select1
79
+ class Select1():
80
80
 
81
- def db_select()
81
+ def db_select():
82
82
 
83
83
  cur_sel = Dbaccess.get_cur()
84
84
 
@@ -100,9 +100,9 @@
100
100
 
101
101
 
102
102
 
103
- class Select2
103
+ class Select2():
104
104
 
105
- def db_select()
105
+ def db_select():
106
106
 
107
107
  cur_sel = Dbaccess.get_cur()
108
108
 

1

誤字

2020/01/25 13:23

投稿

yamadataro3
yamadataro3

スコア12

test CHANGED
@@ -1 +1 @@
1
- postgresのDBのcursor処理https://teratail.com/contact/input
1
+ postgresのDBのcursor処理
test CHANGED
@@ -29,6 +29,8 @@
29
29
  test3 = Select2()
30
30
 
31
31
  test3.db_select()
32
+
33
+
32
34
 
33
35
  -----------------------------------------------------------
34
36