我正在尝试在 python 中使用 pyodbc 运行 SQL 命令。其中SQL命令包含多个SELECT命令和IF语句。
但我收到如下错误
columns = [col_desc[0] for col_desc in cursor.description]
TypeError: 'NoneType' object is not iterable
import pyodbc
import pandas as pd
conn = pyodbc.connect("DRIVER={SQL Server};"
"SERVER=server_name;"
"DATABASE=master;"
"Trusted_Connection=yes;")
cursor = conn.cursor()
script="""
If object_id ('tempdb..#Temp1')is not null
drop table #Temp1
Select distinct a1.some_ID into #Temp1
from DOC.dbo.Document_tbl (NOLOCK)a1
from #Temp1 a1
If object_id ('tempdb..#Temp2')is not null
Drop table #Temp2
select distinct v2.some_data
into #Temp2 from tbl_name (nolock) v2
If object_id ('tempdb..#Results')is not null
drop …Run Code Online (Sandbox Code Playgroud) 在尝试在 python 中安装 pypdfocr 包时出现以下错误。
ERROR: Command errored out with exit status 1:
command: 'c:\users\User\appdata\local\programs\python\python37-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\GIBIN_~1\\AppData\\Local\\Temp\\pip-install-uansf_7f\\evernote\\setup.py'"'"'; __file__='"'"'C:\\U
sers\\GIBIN_~1\\AppData\\Local\\Temp\\pip-install-uansf_7f\\evernote\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base
pip-egg-info
cwd: C:\Users\GIBIN_~1\AppData\Local\Temp\pip-install-uansf_7f\evernote\
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\GIBIN_~1\AppData\Local\Temp\pip-install-uansf_7f\evernote\setup.py", line 6
exec x
^
SyntaxError: Missing parentheses in call to 'exec'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for …Run Code Online (Sandbox Code Playgroud)