| 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') |