samedi 4 juillet 2015

Run sqlite query using connect_db() method

I'm having issues using the method I made to connect to my sqlite db.

def connect_db(dbname):
    try:
        dbconn = sqlite3.connect(dbname)
        #cursor = dbconn.cursor()
    except:
        print ("error connecting to db")

When i try to use connect_db()

conn = connect_db('./syncdb.db')
        cursor = dbconn.cursor()
        cursor.execute('''
            SELECT * FROM paths

        ''')

Anyone know what I'm doing wrong? I've tried a lot of different ways already to use this method connect_db(), but it doesnt seem to be able to work correctly.

Thank you.

Aucun commentaire:

Enregistrer un commentaire