Hello folks, I want to make an insert query in Pos...
# ask-community
q
Hello folks, I want to make an insert query in Postgres can someone give me sweet example using
PostgresExecute
. 🙂
j
Hi Questionnaire, what have you tried? Have you read through the docstring here: https://docs.prefect.io/api/latest/tasks/postgres.html#postgresexecute?
k
This should give you what you need as an example to work with.
Copy code
query3 = """
BEGIN;
  INSERT INTO third_table(username, password, email, created_on)
     VALUES (%s, %s, %s, %s);
"""
with Flow("postgres-example") as flow:
  db_result = PostgresExecute(db_name="<dbname>",
    user="<username>",
    password="<password>,
    host="host",
    port=5432,
    query=query3,
    data=("joesmith18", "abc1234", "<mailto:joe18@email.com|joe18@email.com>", "2020-05-20"),
    commit=False)
👍 1