code
import gspread
import psycopg2
from oauth2client.service_account import ServiceAccountCredentials
scope = ["
creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope)
client = gspread.authorize(creds)
sheet = client.open("report").sheet1
rows = sheet.get_all_values()[1:]
conn = psycopg2.connect("dbname=test user=postgres")
cur = conn.cursor()
cur.executemany("INSERT INTO stats (col1, col2) VALUES (%s, %s)", rows)
conn.commit()
Post #276
32
📋 Автоматизация: перенос данных из Google Sheets в PostgreSQL