|
Python Connector for Google Sheets Using the module - Python Connector for Google Sheets |
|
To retrieve data from Google Sheets:
import devart.googlesheets as googlesheets
connect() module method and obtain a connection object.
response = googlesheets.signin()
my_spreadsheet = googlesheets.getspreadsheet("RefreshToken=" + response["Refresh Token"])
my_connection = googlesheets.connect(
SpreadsheetId=my_spreadsheet["Spreadsheet Id"]
RefreshToken=response["Refresh Token"]
)
cursor object using the cursor() connection method.
my_cursor = my_connection.cursor()
execute() cursor method.
my_cursor.execute("SELECT * FROM Company")
fetch*() cursor methods.
for row in my_cursor.fetchall():
print(row)