質問編集履歴

2

自分で調べたことの追記

2016/11/19 22:58

投稿

nzaki
nzaki

スコア9

test CHANGED
File without changes
test CHANGED
@@ -61,3 +61,17 @@
61
61
 
62
62
 
63
63
  よろしくお願いします。
64
+
65
+
66
+
67
+ 追記:
68
+
69
+ [http://nonbiri-tereka.hatenablog.com/entry/2014/08/17/104650
70
+
71
+ ](http://nonbiri-tereka.hatenablog.com/entry/2014/08/17/104650)
72
+
73
+
74
+
75
+ こちらのサイトを見ると普通にMySQLでも%s指定使えるようですね・・・。
76
+
77
+ バージョンとか見直してみます。

1

ソースコード追加

2016/11/19 22:58

投稿

nzaki
nzaki

スコア9

test CHANGED
File without changes
test CHANGED
@@ -8,13 +8,33 @@
8
8
 
9
9
 
10
10
 
11
- エラーメッセージ
11
+ ###エラーメッセージ
12
12
 
13
+ ```
14
+
15
+ _mysql_exceptions.ProgrammingError:
16
+
17
+ (1064, "You have an error in your SQL syntax;
18
+
13
- _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")
19
+ check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")
20
+
21
+ ```
22
+
23
+ ###ソースコード
24
+
25
+ ```
26
+
27
+ # -*- coding: utf-8 -*-
28
+
29
+ import MySQLdb
14
30
 
15
31
 
16
32
 
17
- ースコード
33
+ # DBに接続しカールを取得する
34
+
35
+ connect = MySQLdb.connect(host='localhost',port=3306,user='test_user',passwd='test_passwd',db='test_db',charset='utf8')
36
+
37
+ cursor = connect.cursor()
18
38
 
19
39
  sql = "select * from test_table where id = %s"
20
40
 
@@ -22,7 +42,17 @@
22
42
 
23
43
  cursor.execute(sql, [whereid]) # select文を実行
24
44
 
45
+ ```
25
46
 
47
+ ###バージョン
48
+
49
+ ```
50
+
51
+ python:3.4
52
+
53
+ mysql:5.5.52
54
+
55
+ ```
26
56
 
27
57
  python,mysqlともに勉強中なのですが、これは構文エラーということでしょうか。
28
58
 
@@ -30,12 +60,4 @@
30
60
 
31
61
 
32
62
 
33
- バージョン
34
-
35
- python:3.4
36
-
37
- mysql:5.5.52
38
-
39
-
40
-
41
63
  よろしくお願いします。