Spaces:
Runtime error
Runtime error
Update src/gsheet.py
Browse files- src/gsheet.py +3 -24
src/gsheet.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
-
import gspread
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
from google.oauth2.service_account import Credentials
|
|
|
|
| 5 |
|
| 6 |
-
SHEET_ID = "1XdzW7Vgd3bYT8f9qTO2vp00OkbdhvhkH5P-23PihXmw"
|
| 7 |
-
|
| 8 |
-
# ==================================
|
| 9 |
-
# 🔐 CONNECT USING HUGGING FACE SECRET
|
| 10 |
-
# ==================================
|
| 11 |
def connect_sheet():
|
| 12 |
|
| 13 |
creds_dict = json.loads(os.environ["GOOGLE_CREDENTIALS"])
|
|
@@ -21,22 +16,6 @@ def connect_sheet():
|
|
| 21 |
)
|
| 22 |
|
| 23 |
client = gspread.authorize(credentials)
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
return sheet
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# ==================================
|
| 30 |
-
# 📥 INSERT DATA
|
| 31 |
-
# ==================================
|
| 32 |
-
def insert_data(data):
|
| 33 |
-
sheet = connect_sheet()
|
| 34 |
-
sheet.append_row(data)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
# ==================================
|
| 38 |
-
# 📤 GET ALL DATA
|
| 39 |
-
# ==================================
|
| 40 |
-
def get_all_data():
|
| 41 |
-
sheet = connect_sheet()
|
| 42 |
-
return sheet.get_all_records()
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
from google.oauth2.service_account import Credentials
|
| 4 |
+
import gspread
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def connect_sheet():
|
| 7 |
|
| 8 |
creds_dict = json.loads(os.environ["GOOGLE_CREDENTIALS"])
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
client = gspread.authorize(credentials)
|
| 19 |
+
sheet = client.open_by_key("YOUR_SHEET_ID").sheet1
|
| 20 |
|
| 21 |
+
return sheet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|