-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite.py
More file actions
50 lines (44 loc) · 1.07 KB
/
sqlite.py
File metadata and controls
50 lines (44 loc) · 1.07 KB
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
42
43
44
45
46
47
48
49
50
import sqlite3
import csv
from pathlib import Path
def init_db():
conn = sqlite3.connect('traffic.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS udp (
id INTEGER PRIMARY KEY AUTOINCREMENT,
start_time REAL,
end_time REAL,
source_ip TEXT,
source_port INTEGER,
destination_ip TEXT,
destination_port INTEGER,
total_size INTEGER,
total_packets INTEGER
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS tcp (
id INTEGER PRIMARY KEY AUTOINCREMENT,
start_time REAL,
end_time REAL,
source_ip TEXT,
source_port INTEGER,
destination_ip TEXT,
destination_port INTEGER,
total_size INTEGER,
total_packets INTEGER
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS dns (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp REAL,
domain_name TEXT,
ip_address TEXT
)
''')
conn.commit()
conn.close()
if __name__ == '__main__':
init_db()