File size: 721 Bytes
4eac606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sqlite3
def print_db_data(db_path):
    # Connect to the SQLite database
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    
    try:
        # Execute a query to read standard data columns
        cursor.execute("SELECT id, email, api_key, created_at FROM accounts")
        rows = cursor.fetchall()
        
        print(f"Found {len(rows)} records:")
        for row in rows:
            print(f"ID: {row[0]}, Email: {row[1]}, API Key: {row[2]}, Created At: {row[3]}")

    except sqlite3.Error as e:
        print(f"An error occurred: {e}")
    finally:
        # Always ensure the connection is closed
        conn.close()
  
if __name__ == "__main__":
    d = print_db_data('db/accounts.db')