質問編集履歴

1

もう少し具体的に書きました

2017/02/13 10:38

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

test CHANGED
File without changes
test CHANGED
@@ -43,3 +43,39 @@
43
43
  _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
44
44
 
45
45
  どのようにクリアすればいいですか?
46
+
47
+ もともとは下記のようになっていました。基本的なことがわかりません
48
+
49
+
50
+
51
+ Import MySQLdb
52
+
53
+ Connection = Mysql>connect(
54
+
55
+ host=”localhost”,
56
+
57
+ port=3306,
58
+
59
+ db=”test”,
60
+
61
+ user=”username”,
62
+
63
+ passwd=”password”,
64
+
65
+ )
66
+
67
+ cursor = connection.cursor()
68
+
69
+ cursor.execute(‘’’CREAT TABLE products (name text, price integer);’’’)
70
+
71
+ cursor.execute(‘’’INSERT INTO products (name, price)VALUES (‘apple’, 198);’’’)
72
+
73
+ cursor.execute(‘’’INSERT INTO products (name, price)VALUES (‘orange’, 100);’’’)
74
+
75
+ connection.commit()
76
+
77
+ cursor.execute(‘’’SELECT * FROM products:’’’)
78
+
79
+ products = cursor.fetchall()
80
+
81
+ print(products) # -> ((‘apple’, 198L), (‘orange’, 100L))