| import sqlite3 |
|
|
| def generate_double_entry(text): |
| |
| if "furniture" in text: |
| return ("Office Furniture", "Cash", 1000) |
| elif "rent" in text: |
| return ("Rent Expense", "Bank", 2000) |
| else: |
| return ("Uncategorized Debit", "Uncategorized Credit", 0) |
|
|
| def save_transaction(debit, credit, amount, description): |
| conn = sqlite3.connect("db.sqlite") |
| cursor = conn.cursor() |
| cursor.execute(""" |
| CREATE TABLE IF NOT EXISTS transactions ( |
| id INTEGER PRIMARY KEY AUTOINCREMENT, |
| debit TEXT, credit TEXT, amount REAL, description TEXT |
| ) |
| """) |
| cursor.execute(""" |
| INSERT INTO transactions (debit, credit, amount, description) |
| VALUES (?, ?, ?, ?) |
| """, (debit, credit, amount, description)) |
| conn.commit() |
| conn.close() |
|
|