The following code yields an error that says the database is locked:
df_chunks = pd.read_sql('cdr', engine, chunksize=100000)
engine.dispose()
with engine.connect() as conn:
trans = conn.begin()
query = """
CREATE TABLE test (row_id BIGINT,ego_id BIGINT,alter_id BIGINT)
"""
print(query)
conn.execute(query)
trans.commit()
conn.close()
but if I do it the other way around:
with engine.connect() as conn:
trans = conn.begin()
query = """
CREATE TABLE test (row_id BIGINT,ego_id BIGINT,alter_id BIGINT)
"""
print(query)
conn.execute(query)
trans.commit()
conn.close()
df_chunks = pd.read_sql('cdr', engine, chunksize=100000)
it works and I am able to generate the new table. So from here, it seems that the problem is that pd.read_sql (see docs) locks the database. I found this question but engine.dispose() didn't work for me. What's the way to go around this problem?