【发布时间】:2020-02-11 21:21:56
【问题描述】:
对不起,如果我命名错误,这是我第一次尝试在 python 中制作一些工作脚本。我使用Dictionary Cursor 列出了列表,但我现在需要将其用作变量并删除文件夹。例如。
如果我会在/data/system/domain.tld 和domain.tld 中找到我在 ["name"] 中的选择中列出,我想删除该目录。当我想要这个功能时,我应该如何处理我的代码?
import pymysql.cursors
import os
connection = pymysql.connect(host='localhost',
user='root',
password='password',
db='database',
cursorclass=pymysql.cursors.DictCursor)
cursor = connection.cursor()
sql="SELECT id, name, state FROM domain WHERE state='2'"
cursor.execute(sql)
records = cursor.fetchall()
print("Total number of records for deleting is: ", cursor.rowcount)
print("\nPrinting each domain record")
for row in records:
print (row)
print("id = ", row["id"], )
print("name = ", row["name"])
print("state = ", row["state"], "\n")
【问题讨论】:
标签: mysql python-3.x pymysql