sybrenstuvel/flickrapi

sqlite3.OperationalError: no such table: oauth_tokens

hunterji opened this issue · 6 comments

I am using version 2.1.2 of the library on Windows 10 with Python 3.6.0. When I run this code:
flickr = flickrapi.FlickrAPI(api_key, api_secret)

I get this stack:
File "\lib\site-packages\flickrapi\core.py", line 201, in __init__ self.flickr_oauth = auth.OAuthFlickrInterface(api_key, secret, self.token_cache) File "\lib\site-packages\flickrapi\auth.py", line 159, in __init__ if oauth_token.token: File "\lib\site-packages\flickrapi\tokencache.py", line 179, in token (self.api_key, self.lookup_key)) sqlite3.OperationalError: no such table: oauth_tokens

Looking into the sqlite3 database it looks like the oauth_cache_db_version table gets created with a version field. But the field is never populated and oauth_tokens table isn't created at all.

If I add a db.commit() as the last line in the create_table method of the OAuthTokenCache class in tokencache.py it seems to work. The tables and fields are created and when I authorize my account on Flickr the token information gets stored.

I was going to create a PR, but I wasn't sure this was really the correct/best fix. It just happens to be the one that works for me.

It looks like the proper fix. If you can, please create a PR, and also run the unittests to see that it didn't break anything else.

Sounds good. I'll give it a shot.

I didn't want to start a new thread, but i'm getting this exact error using flickrapi-2.2.1 with Python 3.5.0 and Python 3.6.1 when installing from pip. It seems the db.commit() fix is missing.

Not opening a new thread is fine.
You still see the error because it was fixed in February, but the last release was from January. You should be able to do pip install git+https://github.com/sybrenstuvel/flickrapi.git to install the current master branch directly from Github.

Sorry, I used your method but it doesn't work.Now do you have any other method?

Please add the -U option to that pip install command so that it actually allows upgrading the already-installed package.