Skip to main content
Glama
by clipsense
reset_usage_direct.py2.07 kB
#!/usr/bin/env python3 """ Direct database reset script for API key usage. Run this with Railway database credentials to reset usage limits. """ import sys try: import psycopg2 from psycopg2 import sql except ImportError: print("Installing psycopg2...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "psycopg2-binary"]) import psycopg2 from psycopg2 import sql # Database URL format: postgresql://user:password@host:port/database # You can get this from Railway dashboard under your database service DATABASE_URL = input("Enter Railway DATABASE_URL (or press Enter to skip): ").strip() if not DATABASE_URL: print("\n⚠️ No DATABASE_URL provided.") print("\nTo reset API key usage:") print("1. Go to Railway dashboard: https://railway.app/dashboard") print("2. Select your ClipSense project") print("3. Click on the Postgres service") print("4. Go to 'Data' tab") print("5. Run this SQL query:") print("\n UPDATE api_keys") print(" SET usage_count = 0, analyses_used = 0") print(" WHERE key = 'cs_sk_pNQhgId_0X8P-gt010CkRfZ4cgVVAejH9JQj_LpPmYg';") print("\nOr provide the DATABASE_URL when running this script.") sys.exit(0) try: print("\n🔄 Connecting to database...") conn = psycopg2.connect(DATABASE_URL) cur = conn.cursor() # Reset usage for the test API key api_key = "cs_sk_pNQhgId_0X8P-gt010CkRfZ4cgVVAejH9JQj_LpPmYg" cur.execute( "UPDATE api_keys SET usage_count = 0, analyses_used = 0 WHERE key = %s RETURNING key, usage_count, analyses_used", (api_key,) ) result = cur.fetchone() conn.commit() if result: print(f"✅ Successfully reset usage for API key!") print(f" Key: {result[0][:20]}...") print(f" Usage count: {result[1]}") print(f" Analyses used: {result[2]}") else: print("❌ API key not found in database") cur.close() conn.close() except Exception as e: print(f"❌ Error: {e}") sys.exit(1)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/clipsense/-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server