New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite3.OperationalError: no such table: oauth_tokens #75

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

Comments

Projects
None yet
4 participants
@hunterji
Copy link
Contributor

hunterji commented Jan 15, 2017

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

This comment has been minimized.

Copy link
Owner

sybrenstuvel commented Jan 15, 2017

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

This comment has been minimized.

Copy link
Contributor Author

hunterji commented Jan 16, 2017

Sounds good. I'll give it a shot.

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

Commit database after creating oauth_tokens table. Fixes sybrenstuvel#75


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

This comment has been minimized.

Copy link

sharkwheels commented Apr 11, 2017

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

This comment has been minimized.

Copy link
Owner

sybrenstuvel commented Apr 12, 2017

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

sybrenstuvel commented Sep 25, 2017

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 join this conversation on GitHub. Already have an account? Sign in to comment