33 lines
855 B
Python
Executable File
33 lines
855 B
Python
Executable File
import psycopg2
|
|
import os
|
|
|
|
conn = psycopg2.connect(
|
|
host="localhost",
|
|
database="mydatabase",
|
|
user="myuser",
|
|
password="mypassword",
|
|
port="5432" # Default PostgreSQL port
|
|
)
|
|
|
|
|
|
directory_path = "/home/geezo/01_projects/decorrupt/motherload/scan" # Replace with your directory
|
|
all_entries = os.listdir(directory_path)
|
|
|
|
files = [entry for entry in all_entries if os.path.isfile(os.path.join(directory_path, entry))]
|
|
#print(files)
|
|
|
|
|
|
try:
|
|
cursor = conn.cursor()
|
|
for file in files:
|
|
cursor.execute(f"INSERT INTO public.decorrupt (filename, ref_x, ref_12, ref_16) VALUES('{file}', 0, 0, 0)")
|
|
|
|
conn.commit()
|
|
except psycopg2.Error as e:
|
|
print(f"Error connecting to or querying the database: {e}")
|
|
finally:
|
|
# 6. Close Cursor and Connection
|
|
if cursor:
|
|
cursor.close()
|
|
if conn:
|
|
conn.close() |