Skip to content

Instantly share code, notes, and snippets.

@Bouncner
Created August 17, 2022 08:34
Show Gist options
  • Select an option

  • Save Bouncner/1a4e814289341ca2f7c3edf7436655a8 to your computer and use it in GitHub Desktop.

Select an option

Save Bouncner/1a4e814289341ca2f7c3edf7436655a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import datetime
import os
import psycopg2
import sys
import time
connection = psycopg2.connect("host=rapa.eaalab.hpi.uni-potsdam.de port=5432")
connection.autocommit = True
cursor = connection.cursor()
while True:
print("Starting to run all queries of input file.")
with open("Generated-TPCH-SQL-30.csv") as query_file:
for query_id, query in enumerate(query_file):
start_time = time.time()
print(f" {datetime.datetime.now()}: Starting query #{query_id}", end="")
cursor.execute(query.strip())
result = cursor.fetchall()
print(f" ... done ({time.time() - start_time:.2f} s; {len(result)} rows).")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment