2017-09-16 08:49:46 +08:00
|
|
|
import sqlite3
|
|
|
|
import pycountry
|
2017-10-20 20:59:21 +08:00
|
|
|
import os
|
2017-09-16 08:49:46 +08:00
|
|
|
|
|
|
|
# Get languages list in langs tuple
|
|
|
|
langs = [[lang.alpha_3,lang.alpha_2,lang.name]
|
|
|
|
for lang in pycountry.languages
|
|
|
|
if hasattr(lang, 'alpha_2')]
|
|
|
|
|
|
|
|
# Open database connection
|
2017-12-05 08:01:10 +08:00
|
|
|
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
2017-09-16 08:49:46 +08:00
|
|
|
c = db.cursor()
|
|
|
|
|
|
|
|
# Insert languages in database table
|
|
|
|
c.executemany('''INSERT OR IGNORE INTO table_settings_languages(code3, code2, name) VALUES(?, ?, ?)''', langs)
|
|
|
|
|
|
|
|
# Commit changes to database table
|
|
|
|
db.commit()
|
|
|
|
|
|
|
|
# Close database connection
|
|
|
|
db.close()
|