-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_database.py
More file actions
39 lines (21 loc) · 748 Bytes
/
read_database.py
File metadata and controls
39 lines (21 loc) · 748 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
37
38
39
import sqlite3
import pandas as pd
db_path = r'C:\Users\itcomplex\Desktop\vscpp\vault.db'
db_path = r'C:\Users\itcomplex\Desktop\vscpp\vault.db'
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
print("Tables in the database:")
for table in tables:
print(table[0])
conn = sqlite3.connect(db_path)
query = "SELECT * FROM entities LIMIT 5"
df = pd.read_sql_query(query, conn)
print("Column Names:", df.columns)
print(df.head())
conn.close()
df['date_created'] = pd.to_datetime(df['date_created'])
print(df['date_created'].describe() )
print(df['country_code'].value_counts())
print(df['server_state'].value_counts())