import psycopg2
import threading
DB_NAME = 'vacuum'
DB_USER = 'agens'
DB_PASSWORD = 'agens'
DB_HOST = '192.168.54.52'
DB_PORT = '53333'
THREAD_COUNT = 100
START_VALUE = 40
END_VALUE = 100000000
def insert_values():
conn = psycopg2.connect(
dbname=DB_NAME,
user=DB_USER,
password=DB_PASSWORD,
host=DB_HOST,
port=DB_PORT
)
conn.autocommit=True
cursor = conn.cursor()
for i in range(START_VALUE, END_VALUE + 1):
cursor.execute("INSERT INTO vacuum6 (int) VALUES (%s)", (i,))
conn.commit()
conn.close()
threads = []
for _ in range(THREAD_COUNT):
thread = threading.Thread(target=insert_values)
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("값 추가 완료")