blob: 6c3e5b02b61d9b2aa0a491495a0b9e29b88001b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import sqlite3
import csv
def print_sqlite(cursor):
for row in cursor.fetchall():
print(dict(row))
def create_csv_from_sqlite(data):
with open("sqlite_output.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["id", "url", ...])
writer.writerows(data)
def get_url_from_sqlite(sqlite_file, title):
con = sqlite3.connect(sqlite_file)
con.row_factory = sqlite3.Row
cur = con.cursor()
select_statement = "SELECT url FROM moz_places WHERE title = ?"
dat = cur.execute(select_statement, (title,))
row = dat.fetchone()
if row:
return row["url"]
return None
def main():
get_url_from_sqlite(
"chsokl11/places.sqlite", "Atmosphärische Gegenstrahlung – Wikipedia"
)
# create_csv_from_sqlite(dat)
# concat_logfiles()
if __name__ == "__main__":
main()
|