0

WITH句を使った以下のようなSQLをSQLite3で実行すると、正常に実行できます。

WITH order_3 AS 
(
    SELECT
     item_id
    FROM
      order
    WHERE
     ordernum >= 3
)
SELECT
  i.itemcode,
  i.itemname,
  i.price
FROM
  items AS i
  JOIN order_3 as o ON o.item_id = i.id
ORDER BY
 i.itemcode ASC

このSQLをPython3のsqliteモジュールを使って、以下のようなプログラムを実行するとSyntaxErrorになってしまいます。

import sqlite3
connection = sqlite3.connect("hoge.sqlite3")
cursor = connection.cursor()
cursor.execute(sql)

Pythonのsqlite3は、WITH句の実行をサポートしていないんでしょうか・・・?

2

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。