+ # iterate through the tables in the page
+ list_table = soup.find_all("table", attrs={"class":"wikitable"})
+ print("iterating through tables")
+ for table in list_table:
+ for row in table.tbody.find_all("tr", recursive=False):
+ cell = row.find_all("td", recursive=False)
+ if len(cell) > 2:
+ print(i, end="\r")
+ latin = (cell[0].get_text(" ", strip=True)).rstrip()
+ english = (cell[1].get_text(" ", strip=True)).rstrip()
+ notes = (cell[2].get_text(" ", strip=True)).rstrip()
+
+ c.execute("""INSERT INTO phrases (id, latin, english, notes, length)
+ VALUES(?, ?, ?, ?, ?)""", (i, latin, english, notes, len(latin)))
+ conn.commit()
+
+ i = i + 1
+
+ print("closing database")
+ c.close()
+ conn.close()