Note location of cursor. At first I thought it was the lack of a semi colon, but as you can see, putting one in does not solve the problem or change the error. I compared this code to samples I found on http://initd.org/psycopg/docs/usage.html :
Based on this, I don't see the problem. FWIW, Pylint in ST3 has no issues with this code. thanks.
from os import getcwd, listdir import psycopg2 from io import open conn = psycopg2.connect("dbname=ktab user=malikarumi") cur = conn.cursor() path = getcwd() filenames = listdir(path) for filename in filenames: with open(filename, 'rb') as f: f1 = f.read() cur.execute("INSERT INTO testable (title, content, chron_date, clock)\ VALUES (%s, %s, %s, %s);"), (filename, f1, '2017-12-30', '23:59:00'), conn.commit() cur.close() conn.close()