Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python (42000、[42000][Microsoft][SQL Server的ODBC驱动程序17][SQL Server]靠近s.(102)(SQLExecDirectW)的语法不正确)_Python_Sql_Sql Server - Fatal编程技术网

Python (42000、[42000][Microsoft][SQL Server的ODBC驱动程序17][SQL Server]靠近s.(102)(SQLExecDirectW)的语法不正确)

Python (42000、[42000][Microsoft][SQL Server的ODBC驱动程序17][SQL Server]靠近s.(102)(SQLExecDirectW)的语法不正确),python,sql,sql-server,Python,Sql,Sql Server,我正在用python编写以下sql代码,但不知道是什么错误,也不知道为什么会出现此错误: query=''' SELECT FIN AS 'LIN', CUSIP, Borrower_Name, Alias, DS_Maturity, Spread, Facility, Facility_Size, Log_date FR

我正在用python编写以下sql代码,但不知道是什么错误,也不知道为什么会出现此错误:

query='''
    SELECT 
        FIN AS 'LIN', 
        CUSIP, 
        Borrower_Name, 
        Alias,
        DS_Maturity, 
        Spread, 
        Facility, 
        Facility_Size, 
        Log_date
    FROM [Main].[FacilityInformation]
    WHERE 
        CUSIP IN ('{}') 
        OR (
            YEAR(DS_Maturity) IN ('{}') 
            AND (
                Borrower_Name IN ('{}') 
                OR Alias IN ('{}')
            )
        )
'''
试着这样做:

query='''
    SELECT 
        FIN AS ''LIN'', 
        CUSIP, 
        Borrower_Name, 
        Alias,
        DS_Maturity, 
        Spread, 
        Facility, 
        Facility_Size, 
        Log_date
    FROM [Main].[FacilityInformation]
    WHERE 
        CUSIP IN ('{}') 
        OR (
            YEAR(DS_Maturity) IN ('{}') 
            AND (
                Borrower_Name IN ('{}') 
                OR Alias IN ('{}')
            )
        )
'''

试着这样做:

query='''
    SELECT 
        FIN AS ''LIN'', 
        CUSIP, 
        Borrower_Name, 
        Alias,
        DS_Maturity, 
        Spread, 
        Facility, 
        Facility_Size, 
        Log_date
    FROM [Main].[FacilityInformation]
    WHERE 
        CUSIP IN ('{}') 
        OR (
            YEAR(DS_Maturity) IN ('{}') 
            AND (
                Borrower_Name IN ('{}') 
                OR Alias IN ('{}')
            )
        )
'''


您在这里发布的查询将很好地解析。假设为了简洁起见,您将值列表缩短为{}。可能需要一些转义字符用于这些单引号。查询中没有
s.
。您在此处发布的查询将很好地解析。假设为了简洁起见,将值列表缩短为{}。可能需要一些转义字符用于这些单引号。查询中没有
s.