|
|
import sqlite3
|
|
|
import pandas as pd
|
|
|
import os
|
|
|
|
|
|
|
|
|
db_path = r'c:\Users\xcool\Downloads\civitai\civitai.sqlite'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
search_term = "direct22202"
|
|
|
query = "SELECT * FROM models WHERE username = '{search_term}';"
|
|
|
|
|
|
|
|
|
output_filename = f'search_results_for_{search_term}.csv'
|
|
|
|
|
|
if not os.path.exists(db_path):
|
|
|
print(f"Error: The file was not found at the path: {db_path}")
|
|
|
else:
|
|
|
conn = None
|
|
|
try:
|
|
|
conn = sqlite3.connect(db_path)
|
|
|
print(f"Successfully connected. Searching for models by username '{search_term}'...")
|
|
|
|
|
|
df = pd.read_sql_query(query, conn)
|
|
|
|
|
|
if df.empty:
|
|
|
print("\nNo models found for that username.")
|
|
|
else:
|
|
|
|
|
|
print("\n--- Found Models ---")
|
|
|
print(df)
|
|
|
|
|
|
|
|
|
df.to_csv(output_filename, index=False)
|
|
|
print(f"\n✅ Success! The results have also been saved to '{output_filename}'")
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"An error occurred: {e}")
|
|
|
finally:
|
|
|
if conn:
|
|
|
conn.close()
|
|
|
print("\nDatabase connection closed.") |