0
conn = psycopg2.connect("dbname=name host=host user=user password=pass port=port")
cur = conn.cursor()
with open('big shot.json') as f:
    data = json.load(f)
for key in data["permissions"]:
    cur.execute("INSERT INTO permissions (name) VALUES (%s);", (key,))
conn.commit()
output = cur.execute("SELECT * FROM permissions")
print(output)

I have this that I'm trying to use to create new rows in my database, but it doesn't do anything. It doesn't return any errors, but it also doesn't write to my database, and output, obviously, returns "None" in the console.

0

1 Answer 1

2

You need to fetch the data from the cursor:

cur.execute("SELECT * FROM permissions")
data = cur.fetchall()
print(data)
Sign up to request clarification or add additional context in comments.

1 Comment

Well I feel dumb, I did that and it output the same thing a bunch of times cuz I've run this so many times lmao

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.