简体   繁体   English

Pypyodbc TabError:缩进中制表符和空格的不一致使用

[英]Pypyodbc TabError: inconsistent use of tabs and spaces in indentation

This is a common problem it seems on here but in my case I cant find an answer.这是一个常见的问题,似乎在这里,但就我而言,我找不到答案。 Why is it saying inconsistent use of tabs and indentation here为什么这里说制表符和缩进的使用不一致

def exectute_SQL():    #This function executes SQL to pull counts from a table where it wasnt possible to get an excel 
    con = pypyodbc.connect(conn_str)
    cur = con.cursor()
    sql = "SELECT * FROM Elig_Own.DST_Report_Validation_Test" #WHERE ysn_active = '1'"
    cur.execute(sql)

    rows = cur.fetchall()

    for row in rows:
        strFnd = 0
        strReportName = row[1]
        strSrcName = row[2]
        strDestName = row[3]
        strFileName = row[4]
        try:
            for report in strReportName:
                if report == 'STR_DB Load to SQL':
                    cur.execute("$result = SELECT TOP 1 COUNT(*) FROM Elig_Own.STR_DB GROUP BY LAST_UPDATED ORDER BY LAST_UPDATED DESC;")
                    cur.execute("INSERT INTO Elig_Own.DST_Report_Status_Test(TDate, Report, Records, Status) VALUES(CAST(GetDate() AS Date), 'STR_DB Load to SQL', ?, 'Passed')",(result))
                    con.commit()
        except:
            print("Couldnt execute script")

And This is the error message这是错误信息

C:\Users\cn192406\Documents\Programs>python File_Check_Dart_Functions.py
File "File_Check_Dart_Functions.py", line 73
cur.execute("$result = SELECT TOP 1 COUNT(*) FROM Elig_Own.STR_DB GROUP BY LAST_UPDATED ORDER BY LAST_UPDATED DESC;")

TabError: inconsistent use of tabs and spaces in indentation TabError:缩进中制表符和空格的使用不一致

Try this:尝试这个:

def exectute_SQL():  # This function executes SQL to pull counts from a table where it wasnt possible to get an excel
    con = pypyodbc.connect(conn_str)
    cur = con.cursor()
    sql = "SELECT * FROM Elig_Own.DST_Report_Validation_Test"  # WHERE ysn_active = '1'"
    cur.execute(sql)

    rows = cur.fetchall()

    for row in rows:
        strFnd = 0
        strReportName = row[1]
        strSrcName = row[2]
        strDestName = row[3]
        strFileName = row[4]
        try:
            for report in strReportName:
                if report == "STR_DB Load to SQL":
                    cur.execute(
                        "$result = SELECT TOP 1 COUNT(*) FROM Elig_Own.STR_DB GROUP BY LAST_UPDATED ORDER BY LAST_UPDATED DESC;"
                    )
                    cur.execute(
                        "INSERT INTO Elig_Own.DST_Report_Status_Test(TDate, Report, Records, Status) VALUES(CAST(GetDate() AS Date), 'STR_DB Load to SQL', ?, 'Passed')",
                        (result),
                    )
                    con.commit()
        except Exception as e:
            pass

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pycharm TabError:在缩进中使用不一致的制表符和空格 - Pycharm TabError: inconsistent use of tabs and spaces in indentation TabError:缩进错误中制表符和空格的使用不一致 - TabError: inconsistent use of tabs and spaces in indentation Error Scrapy TabError:缩进中的制表符和空格不一致使用 - Scrapy TabError: inconsistent use of tabs and spaces in indentation TabError:在缩进中使用不一致的制表符和空格 - TabError: inconsistent use of tabs and spaces in indentation TabError:缩进中制表符和空格的使用不一致(除了:^) - TabError: inconsistent use of tabs and spaces in indentation (except: ^) 使用 Vim Retab 解决 TabError:在缩进中使用制表符和空格不一致? - Use Vim Retab to solve TabError: inconsistent use of tabs and spaces in indentation? 如何修复 - TabError:在缩进中使用不一致的制表符和空格 - How to fix - TabError: inconsistent use of tabs and spaces in indentation TabError:添加到字典时在缩进中使用制表符和空格不一致 - TabError: inconsistent use of tabs and spaces in indentation when adding to a dictionary TabError:在缩进中使用不一致的制表符和空格 | 编写一个简单的计算器 - TabError: inconsistent use of tabs and spaces in indentation | Coding a simple calculator 什么是 TabError:缩进中制表符和空格的使用不一致,为什么会出现? - What is TabError: inconsistent use of tabs and spaces in indentation and why is it raised?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM