Sorry if I named it wrong, this is my first try in python make some working script. I made list with Dictionary Cursor
, but I need now to work with is as variables and delete folders. For example.
If I will found in /data/system/domain.tld
and domain.tld
is listed in from my select in ["name"] I want to delete that directory. How should I proceed with my code when I want this functionality?
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")