-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.py
More file actions
38 lines (23 loc) · 740 Bytes
/
database.py
File metadata and controls
38 lines (23 loc) · 740 Bytes
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
import sqlite3
import datetime
dataRegistro = datetime.datetime.now()
conn = sqlite3.connect('db.sql')
cursor = conn.cursor()
try:
cursor.execute(""" CREATE TABLE site
(url text,
status_code integer,
status_text text,
date timestamp)
""")
print("Criando Tabela!")
except:
print("Tabela ja existe!")
status = ['http://www.xxxxxxx.com.br','500','Site ok',dataRegistro]
conn.execute("INSERT INTO site (url,status_code,status_text,date) VALUES (?,?,?,?)", (status[0],status[1],status[2],status[3]))
conn.commit()
sql = """
SELECT * FROM site
WHERE status_code LIKE '500' """
cursor.execute(sql)
print(cursor.fetchall())