Upload current progress
This commit is contained in:
71
test_connection.py
Executable file
71
test_connection.py
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Quick test to verify CouchDB connection and show available files
|
||||
"""
|
||||
import couchdb
|
||||
from urllib.parse import quote
|
||||
|
||||
# Configuration
|
||||
USER = "admin"
|
||||
PASSWORD = "DonCucarach0!?"
|
||||
IP_ADDRESS = "100.100.112.48"
|
||||
PORT = "5984"
|
||||
DB_NAME = "obsidiandb"
|
||||
|
||||
def test_connection():
|
||||
print("Testing CouchDB Connection...")
|
||||
print(f"URL: http://{IP_ADDRESS}:{PORT}/")
|
||||
print(f"Database: {DB_NAME}")
|
||||
print("-" * 60)
|
||||
|
||||
try:
|
||||
# Build URL with credentials
|
||||
safe_password = quote(PASSWORD, safe="")
|
||||
safe_username = quote(USER, safe="")
|
||||
url = f"http://{safe_username}:{safe_password}@{IP_ADDRESS}:{PORT}/"
|
||||
|
||||
# Connect
|
||||
server = couchdb.Server(url)
|
||||
print(f"✅ Server Version: {server.version()}")
|
||||
|
||||
# List databases
|
||||
dbs = list(server)
|
||||
print(f"✅ Available Databases: {dbs}")
|
||||
|
||||
# Check if our database exists
|
||||
if DB_NAME not in dbs:
|
||||
print(f"❌ Database '{DB_NAME}' not found!")
|
||||
return False
|
||||
|
||||
# Connect to database
|
||||
db = server[DB_NAME]
|
||||
info = db.info()
|
||||
print(f"✅ Database '{DB_NAME}' found")
|
||||
print(f" - Document Count: {info['doc_count']}")
|
||||
print(f" - Update Sequence: {info['update_seq']}")
|
||||
|
||||
# List some files
|
||||
print("\n📁 Sample Files:")
|
||||
count = 0
|
||||
for row in db.view('_all_docs', include_docs=True, limit=10):
|
||||
doc = row.doc
|
||||
if "children" in doc and isinstance(doc.get("children"), list):
|
||||
path = doc.get("path", doc["_id"])
|
||||
num_chunks = len(doc["children"])
|
||||
print(f" - {path} ({num_chunks} chunks)")
|
||||
count += 1
|
||||
|
||||
if count == 0:
|
||||
print(" ⚠️ No file metadata documents found (showing first 10 docs)")
|
||||
for row in db.view('_all_docs', limit=10):
|
||||
print(f" - {row.id}")
|
||||
|
||||
print("\n✅ Connection test successful!")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Connection failed: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_connection()
|
||||
Reference in New Issue
Block a user