1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-26 09:37:25 +00:00
bazarr/get_languages.py
Louis Vézina 5d1aacddd1 Test
2017-11-27 23:09:24 -05:00

21 lines
580 B
Python

import sqlite3
import pycountry
import os
# 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
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
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()