This might be a pretty naive way of doing it, but have you try pandas
? Pandas might add a little bit of overhead, but it's definitely useful for this kind of tasks, and it's not particularly slow for sqlite (another story with PostgreSQL).
import pandas as pd
import sqlite3
conn = sqlite3.connect('prueback.db')
cur = conn.cursor()
# Don't know which type of file you have. I'm assuming a fixed width column text
data = pd.read_fwf('subgenres.txt')
# This will create the table, or add rows if exists (just change the if_exists option to "append")
data.to_sql('subgenero', conn, if_exists='replace')
conn.close()
Now, if you have another table in you database you can pull the data from the database using Pandas:
table_db = pd.read_sql("select * from table", con=conn)
# In case they have identifiers (or if they keep the same row order)
table_db['subgenero'] = table_db.merge(suborder, on='id' ,how='inner')
table_db.to_sql('table', conn, if_exists='replace')
Check more information in the Pandas documentation
and read with particular attention the pd.to_sql
documentation, there is a lot of options that might be particularly helpful depending on your use case.