65 lines
2.0 KiB
Python
65 lines
2.0 KiB
Python
|
|
import couchdb
|
||
|
|
from urllib.parse import quote
|
||
|
|
|
||
|
|
# Configuration
|
||
|
|
user = "admin"
|
||
|
|
password = "DonCucarach0!?"
|
||
|
|
# Note: Removed /_utils/ as that is the UI path, not the API root
|
||
|
|
base_host = "diego-server.tailc07c18.ts.net"
|
||
|
|
db_name = "obsidiandb"
|
||
|
|
|
||
|
|
# Safe URL Construction
|
||
|
|
safe_password = quote(password, safe="")
|
||
|
|
# Assuming HTTPS since it's a tailscale domain
|
||
|
|
url = f"https://{user}:{safe_password}@{base_host}/"
|
||
|
|
|
||
|
|
print(f"Attempting connection to: https://{base_host}/")
|
||
|
|
print(f"Target Database: {db_name}")
|
||
|
|
|
||
|
|
try:
|
||
|
|
# 1. Connect
|
||
|
|
server = couchdb.Server(url)
|
||
|
|
print(f"✅ Server Connected! Version: {server.version()}")
|
||
|
|
|
||
|
|
# 2. Check Database
|
||
|
|
if db_name in server:
|
||
|
|
db = server[db_name]
|
||
|
|
print(f"✅ Database '{db_name}' found.")
|
||
|
|
print(f"📊 Total Documents: {len(db)}")
|
||
|
|
|
||
|
|
# 3. Peek at Data
|
||
|
|
print("\n--- Sample Notes (First 5) ---")
|
||
|
|
count = 0
|
||
|
|
for doc_id in db:
|
||
|
|
# Skip internal CouchDB design documents
|
||
|
|
if doc_id.startswith("_design"):
|
||
|
|
continue
|
||
|
|
|
||
|
|
if count >= 5: break
|
||
|
|
|
||
|
|
doc = db[doc_id]
|
||
|
|
print(f"📄 ID: {doc_id}")
|
||
|
|
|
||
|
|
# Check for content fields common in Obsidian LiveSync
|
||
|
|
content = doc.get("data") or doc.get("content")
|
||
|
|
|
||
|
|
if content:
|
||
|
|
preview = str(content)[:100].replace("\n", " ")
|
||
|
|
print(f" Content: {preview}...")
|
||
|
|
else:
|
||
|
|
print(" [No 'data' or 'content' field found - might be a metadata chunk]")
|
||
|
|
|
||
|
|
print("-" * 30)
|
||
|
|
count += 1
|
||
|
|
|
||
|
|
if count == 0:
|
||
|
|
print("Database is empty or only contains design docs.")
|
||
|
|
|
||
|
|
else:
|
||
|
|
print(f"❌ Database '{db_name}' NOT found.")
|
||
|
|
print("Available Databases:", list(server))
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"\n❌ Connection Failed: {e}")
|
||
|
|
print("Tip: Ensure you are connected to Tailscale and the URL includes https://")
|