Python错误:AttributeError:' tuple'对象没有属性'小写'?

时间:2017-12-11 16:44:18

标签: python python-2.7 list tuples pyodbc

(我在这里非常业余,所以放轻松!)。我似乎无法克服这个错误:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 31, in <module>
AttributeError: 'tuple' object has no attribute 'lowercase'

以下是我的代码的简化版本:

import pyodbc

#connect to SQL Server database
db=pyodbc.connect("DRIVER={SQL Server Native Client 11.0};SERVER=NotAChance;DATABASE=theCan;UID=HAHA;PWD=NotGonnaTell;")

#set the database cursor
c=db.cursor()

#SQL for getting PIDs that have feature classes locked
c.execute("""SELECT DISTINCT sde.SDE_table_locks.*,
sde.SDE_process_information.start_time,
sde.SDE_process_information.owner,
sde.SDE_process_information.nodename,
sde.SDE_process_information.direct_connect,
sde.SDE_table_registry.table_name
FROM sde.SDE_table_locks
INNER JOIN sde.SDE_table_registry ON sde.SDE_table_locks.registration_id = sde.SDE_table_registry.registration_id
WHERE (sde.SDE_table_registry.table_name) Like '%%'""")

#Create a list to dump PIDs in to, so we can weed down to unique ones
mylist = []

#Loop through the PIDs 
for (a, b, c, d, e, f, g, h, i) in c.fetchall():

    #add the PID that needs to be killed to a list
    mylist.append(b)
    #print (mylist)

#weed the list of PIDs down to just the unique PIDs
pids_to_kill = dict(map(lambda i: (i,1),mylist)).keys()

arcpy.AddMessage(pids_to_kill)

#reset the cursor
c=db.cursor()

#loop through the unique PIDs and delete each lock record
for i in pids_to_kill:
    c.execute("DELETE FROM sde.SDE_table_locks WHERE sde.SDE_table_locks.registration_id = " + str(i))
    c=db.cursor()

#commit the changes
db.commit()

#disconnect
db.close()

我无法理解它与我的元组有关的问题。我在代码中的任何地方都没有使用.lower()做任何事情。

我使用Python 2.7并在ArcGIS 10.5(python窗口以及脚本工具)中运行它。这可能会进入GIS Stack Exchange,但我不确定它是否与GIS有关。

0 个答案:

没有答案