Reputation: 11
Hi i am updating Google sheet by using google service account,
google drive api and google sheet api.
initially code run succesfully but aftet some time
returning errno110 retry exceeded
My code is
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import json
import pandas as pd
scopes = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
credentials
=ServiceAccountCredentials.from_json_keyfile_name
("client_secret1.json"
, scopes)
file = gspread.authorize(credentials) # authenticate the JSON key
with gspread
wb = file.open("gw_data")
sh = wb.worksheet('dt_trial')
df = pd.DataFrame([[1, 2, 3, 4, 5]],columns = ['Date', 'Time',
'LTP' , 'Ce', 'Pe'])
sh.update([df.columns.values.tolist()] + df.values.tolist())
PLZZ help me i am new at coding
Error
/
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/gspread/client.py", line 121, in open self.list_spreadsheet_files(title, folder_id), File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/gspread/client.py", line 96, in list_spreadsheet_files res = self.request("get", url, params=params).json() File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/gspread/client.py", line 59, in request response = getattr(self.session, method)( File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/requests/sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/auth/transport/requests.py", line 476, in request self.credentials.before_request(auth_request, method, url, request_headers) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/auth/credentials.py", line 133, in before_request self.refresh(request) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/oauth2/service_account.py", line 410, in refresh access_token, expiry, _ = _client.jwt_grant( File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/oauth2/_client.py", line 193, in jwt_grant response_data = _token_endpoint_request(request, token_uri, body) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/oauth2/_client.py", line 161, in _token_endpoint_request response_status_ok, response_data = _token_endpoint_request_no_throw( File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/oauth2/_client.py", line 115, in _token_endpoint_request_no_throw response = request(method="POST", url=token_uri, headers=headers, body=body) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/google/auth/transport/requests.py", line 189, in call six.raise_from(new_exc, caught_exc) File "", line 3, in raise_from google.auth.exceptions.TransportError: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f68f5d0a0>: Failed to establish a new connection: [Errno 110] Connection timed out'))
Upvotes: 1
Views: 984
Reputation: 11
ok i found solution Actually i was running this code from android mobile IDE and in my google sheet setting transfer files only over wi-fi was enabled. And i havent connected to wifi using net through sim card. So I think bot was trying to transfer data but wifi setting not allowing it so time out error was generated.
Now i changed the setting and code is running smoothly
Upvotes: 0