aboutsummaryrefslogtreecommitdiffhomepage
path: root/update_db.py
blob: 7b757e1876d4f24c7f81234f44136cdb3f883e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sqlite3

# Check if database exist
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
    # Open database connection
    db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
    c = db.cursor()
    
    # Execute table modification
    try:
        c.execute('alter table table_settings_providers add column "username" "text"')
        c.execute('UPDATE table_settings_providers SET username=""')
    except:
        pass

    try:
        c.execute('alter table table_settings_providers add column "password" "text"')
        c.execute('UPDATE table_settings_providers SET password=""')
    except:
        pass

    try:
        c.execute('alter table table_shows add column "audio_language" "text"')
    except:
        pass

    # Commit change to db
    db.commit()

    # Close database connection
    db.close()