File size: 552 Bytes
96f792c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sqlite3

def migrate():
    conn = sqlite3.connect("nutrition_app.db")
    cursor = conn.cursor()
    
    try:
        cursor.execute("ALTER TABLE products ADD COLUMN image_path TEXT")
        conn.commit()
        print("Successfully added image_path column to products table")
    except sqlite3.OperationalError as e:
        if "duplicate column name" in str(e):
            print("Column image_path already exists")
        else:
            print(f"Error: {e}")
    finally:
        conn.close()

if __name__ == "__main__":
    migrate()