I play around with python every now and again. Any input on the script is welcome.
I have more code that is in the my first writing of this code(this is the 3rd version) but, looking over it I noticed something that I don't understan.
In the code where I put action='use '+database (this is/was for another part of the code to use) it does not work if I remove it. I don't understan why. Thanks
#! /usr/bin/python3 import pymysql from collections import Counter user = 'xxxxx' password = 'xxxx' host = 'localhost' db = pymysql.connect(host,user,password) def GetData(query): cur = db.cursor() cur.execute(query) data = cur.fetchall() MineData = [] for i in data: if i[0] != 'information_schema' and i[0] != 'phpmyadmin': MineData.append(i[0]) return MineData def GetCount(counter): count = sum(Counter(counter).values()) return count databases = GetData(query='show databases') print('Searching for databases') print('Found '+str(GetCount(databases))+ ' databases') for database in databases: print(database) print() for database in databases: action = GetData(query='use '+database) tables = GetData(query='show tables') print('Found '+str(GetCount(GetData(query='show tables')))+' tables in database '+database) for table in tables: print(table) print() db.close()
I have more code that is in the my first writing of this code(this is the 3rd version) but, looking over it I noticed something that I don't understan.
In the code where I put action='use '+database (this is/was for another part of the code to use) it does not work if I remove it. I don't understan why. Thanks
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts