Shmookoff
Shmookoff

Reputation: 48

Insert value by Fernet.generate_key() into bytea?

I've tried

SQL

CREATE TABLE table_name (key BYTEA, key_uuid UUID)

Python

cur.execute(f"INSERT INTO table_name (key, key_uuid) VALUES({Fernet.generate_key()}, uuid_generate_v4())")

It gives an error:

psycopg2.errors.InvalidTextRepresentation: "j" is not a valid binary digit
LINE 1: ...me (key, key_uuid) VALUES(b'jBB72dwn...
                                     ^

Or am I understanding this wrong..?

Upvotes: 0

Views: 232

Answers (1)

Shmookoff
Shmookoff

Reputation: 48

The issue was that I used f-strings. Don't use them, yeah... Documentation

Thanks @Marth ♥

Upvotes: 2

Related Questions