I have been playing around trying to set up a regular expression argument that looks at password strings in an SQL file and moves the IDs of the records into a list. When made True all entries are added to the list, yet the one incorrect password is still added to the list even though it should not pass the regex argument.
def passwordCheck(filename):
idList = []
con = sqlite3.connect(filename)
cur = con.cursor()
for row in cur.execute("SELECT * FROM data;"):
row[5] = str(row[5])
regScan = re.match(r"(r'^(?=.*[0-9])(?=.*\W).*$')", row[5])
for match in row[5]:
idList.append(row[0])
return idList
def validPass(filename):
idList = []
con = sqlite3.connect(filename)
cur = con.cursor()
for row in cur.execute("SELECT * FROM data;"):
string = pd.Series(row[5])
string[string.str.match(r"(r'^(?=.*[0-9])(?=.*\W).*$')")==True]
if True:
idList.append(row[0])
return idList
Here I have two methods one using regular expressions alone with the SQL file, and the other trying to use pandas to reach the same end.
One password in my database is just "password", while the others have 1 lowercase, uppercase number and special character. My aim is so the incorrect password is flagged and its corresponding user id is placed in the list. So my output should be something like:
[7]
Yet it always comes either blank when I set the argument to False, or all entries are added when I set to True, despite ID: 7 being the only incorrect entry that should be flagged.
Any help will be greatly appreciated.