1 year ago

#259186

test-img

vini8cs

I'm trying to turn a data frame into a sql in python, but I'm aways getting this output: sqlite3.OperationalError: disk I/O error

I've looked for similar topics on stack overflow and google, but I couldn't find any similar case. Can anyone help me?

import os
import tempfile
import sqlite3
import pandas as pd

tmp = tempfile.mktemp()
try:
        tmpDb = sqlite3.connect(tmp)
finally:
        try:
            if os.path.exists(tmp):
                os.remove(tmp)
        finally:
            tmpDb.commit()
accessions= ["WP_010881498.1", "WP_010881746.1", "WP_010881771.1"]
accessions_df = pd.DataFrame(accessions, columns= ['accessions'])
accessions_df.to_sql(name = "query", con = tmpDb, if_exists = 'replace')

python

pandas

dataframe

sqlite

tmp

0 Answers

Your Answer

Accepted video resources