[2ff88f42] einfügen
einfügen
This commit is contained in:
30
inspect_persona_db_v2.py
Normal file
30
inspect_persona_db_v2.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import sys
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
|
||||
NOTION_TOKEN_FILE = "/app/notion_token.txt"
|
||||
PERSONAS_DB_ID = "30588f42-8544-80c3-8919-e22d74d945ea"
|
||||
|
||||
def load_notion_token():
|
||||
with open(NOTION_TOKEN_FILE, "r") as f:
|
||||
return f.read().strip()
|
||||
|
||||
def query_notion_db(token, db_id):
|
||||
url = f"https://api.notion.com/v1/databases/{db_id}/query"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {token}",
|
||||
"Notion-Version": "2022-06-28"
|
||||
}
|
||||
response = requests.post(url, headers=headers)
|
||||
return response.json()
|
||||
|
||||
token = load_notion_token()
|
||||
data = query_notion_db(token, PERSONAS_DB_ID)
|
||||
results = data.get("results", [])
|
||||
for res in results:
|
||||
props = res.get("properties", {})
|
||||
role = "".join([t.get("plain_text", "") for t in props.get("Role", {}).get("title", [])])
|
||||
print(f"Role: {role}")
|
||||
print(json.dumps(props, indent=2))
|
||||
print("-" * 40)
|
||||
Reference in New Issue
Block a user