Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.1 kB
0
Indexable
Never
import sqlite3

# Create a SQLite database and a table to store ID card information
conn = sqlite3.connect('id_cards.db')
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS id_cards (
                    id INTEGER PRIMARY KEY,
                    first_name TEXT,
                    last_name TEXT,
                    date_of_birth TEXT,
                    address TEXT,
                    photo BLOB
                )''')
conn.commit()

# Function to add a new ID card
def add_id_card(first_name, last_name, date_of_birth, address, photo):
    cursor.execute('''INSERT INTO id_cards (first_name, last_name, date_of_birth, address, photo)
                      VALUES (?, ?, ?, ?, ?)''', (first_name, last_name, date_of_birth, address, photo))
    conn.commit()

# Function to retrieve ID card information
def get_id_card(card_id):
    cursor.execute("SELECT * FROM id_cards WHERE id=?", (card_id,))
    return cursor.fetchone()

# Example usage:
add_id_card("John", "Doe", "1990-01-15", "123 Main St", b'binary_photo_data_here')

# Retrieve an ID card by ID
card_info = get_id_card(1)
print(card_info)