“执行Python脚本”模块中的Azure ML:sqlite3不支持公共表表达式

“执行Python脚本”模块中的Azure ML:sqlite3不支持公共表表达式,python,sqlite,common-table-expression,azure-machine-learning-studio,cortana-intelligence,Python,Sqlite,Common Table Expression,Azure Machine Learning Studio,Cortana Intelligence,我昨天遇到了这个问题,当时我正在尝试使用与我在Azure ML中的Apply SQL Transformation module和Azure ML中的sqlite over Python module中使用的相同的sqlite脚本: with tbl as (select * from t1) select * from tbl 以下是我得到的错误: [Critical] Error: Error 0085: The following error occurred during sc

我昨天遇到了这个问题,当时我正在尝试使用与我在Azure ML中的Apply SQL Transformation module和Azure ML中的sqlite over Python module中使用的相同的sqlite脚本:

with tbl as (select * from t1)
select * from tbl
以下是我得到的错误:

[Critical]     Error: Error 0085: The following error occurred during script evaluation, please view the output log for more information:
---------- Start of error message from Python interpreter ----------
  File "C:\server\invokepy.py", line 169, in batch
data:text/plain,Caught exception while executing function: Traceback (most recent call last):
    odfs = mod.azureml_main(*idfs)
  File "C:\pyhome\lib\site-packages\pandas\io\sql.py", line 388, in read_sql
  File "C:\temp\azuremod.py", line 193, in azureml_main
    results = pd.read_sql(query,con)
    coerce_float=coerce_float, parse_dates=parse_dates)
  File "C:\pyhome\lib\site-packages\pandas\io\sql.py", line 1017, in execute
  File "C:\pyhome\lib\site-packages\pandas\io\sql.py", line 1022, in read_sql
    cursor = self.execute(*args)
    raise_with_traceback(ex)
  File "C:\pyhome\lib\site-packages\pandas\io\sql.py", line 1006, in execute
---------- End of error message from Python  interpreter  ----------
    cur.execute(*args)
DatabaseError: Execution failed on sql:  with tbl as (select * from t1)
                    select * from tbl
以及Python代码:

def azureml_main(dataframe1 = None, dataframe2 = None):
    import pandas as pd
    import sqlite3 as lite
    import sys
    con = lite.connect('data1.db')
    con.text_factory = str
    with con:
        cur = con.cursor()

        if (dataframe1 is not None):
            cur.execute("DROP TABLE IF EXISTS t1")
            dataframe1.to_sql('t1',con)
        query = '''with tbl as (select * from t1)
                    select * from tbl'''                      
        results = pd.read_sql(query,con)    

    return results,
将查询替换为以下内容时:

select * from t1
它像预期的那样工作。 您可能知道,公共表表达式是Sqlite中的一个关键特性,在任何函数式语言(如Sqlite)中都必须具备运行递归代码的能力

我还尝试在Azure的Jupyter笔记本中运行我的Python脚本,这也达到了预期效果


Python模块中的Sqlite配置是否可能与Jupyter笔记本和Apply SQL Transformation模块中的配置不同?

我复制了您的问题,并查看了pandas.io.SQL的SQL查询文档。我尝试使用read\u sql\u查询来解决它,但失败了

根据pandas文档,tt似乎不支持使用这种SQL语法

根据我的经验,并根据您的SQL,我尝试将SQL select*from select*from t1作为tbl,而不是您的适用于熊猫的SQL


希望能有帮助。致以最良好的祝愿

答案是尝试添加您想要的特定版本的sqllite3,下面是一个指南。但我也没有在列表中看到sqllite3。。。笔记本电脑和模块包版本很可能不同步。