Pythonでクエリを実行するときに\ Gオプションを使いたいです。Python、mariaDB: Gオプションの使い方は?
\ Gオプションは、クエリ結果を垂直方向に出力します。
select * from exam\G
*************************** 1. row ***************************
col_1: test2
col_2: test2
col_3: test2
*************************** 2. row ***************************
col_1: test3
col_2: test3
col_3: test3
*************************** 3. row ***************************
col_1: test4
col_2: test4
col_3: test4
例えば
は)だから私は、クエリを送信するために() "受験の\ G SELECT * FROM" を実行に使用しました。
ただし、このコマンドは実行されませんでした。エラーになりました
db = pymysql.connect(
host=localhost, port=3306,user=root,passwd=test,db=test,charset=utf8)
cursor = db.cursor()
cursor.execute("select * from exam\G")
data = cursor.fetchall()
for i in data:
print i
...
pymysql.err.ProgrammingError: (1064, u"You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the
right syntax to use near '\\G' at line 1")
pymysqlで\ Gオプションを使用することができませんか?
\ Gと同じ結果を得る方法はありますか?
ありがとうございました。
'\ G'はmysqlコマンドラインツールの特徴であり、サーバではありません。 –