Skip to content
Advertisement

Unable to use Cursor in separate function

I’m currently tryign to learn how to use SQLite3 and am trying to seperate setting up the DB through functions. My second function is where I’m having the error : AttributeError: 'NoneType' object has no attribute 'cursor'. After looking at the SQLite3 doucmentation, I got the impression that it’s best to seperate diffrent methods for the DB into diffrent functions.

Advertisement

Answer

You are not capturing the return value of create_connection. Try to assign the return type to a variable and try again.

I think this should do it, if you have other problems, please edit your question.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement