Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

sqlite3.OperationalError: no such table: oauth_tokens #75

Closed
hunterji opened this issue Jan 15, 2017 · 6 comments
Closed

sqlite3.OperationalError: no such table: oauth_tokens #75

hunterji opened this issue Jan 15, 2017 · 6 comments

Comments

@hunterji
Copy link
Contributor

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.

@sybrenstuvel
Copy link
Owner

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.

@hunterji
Copy link
Contributor Author

Sounds good. I'll give it a shot.

hunterji added a commit to hunterji/flickrapi that referenced this issue Jan 21, 2017


This change seems to be required in Python 3.6.0. It works correctly without the db.commit() in 3.5.2 and earlier. Without the commit the first table, oauth_cache_db_version, gets created, but oauth_tokens does not.
@sharkwheels
Copy link

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.

@sybrenstuvel
Copy link
Owner

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.

@sstary
Copy link

sstary commented Sep 23, 2017

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

@sybrenstuvel
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants