1

How does one bulk insert data with Postgres into QuestDB? The following does not work

CREATE TABLE IF NOT EXISTS employees (employee_id INT, last_name STRING,first_name STRING);
INSERT INTO employees
(employee_id, last_name, first_name)
VALUES
(10, 'Anderson', 'Sarah'),(11, 'Johnson', 'Dale');

1 Answer 1

1

For inserting data in bulk, there are a few options. You can use CREATE AS SELECT to bulk insert from an existing table which is closest to your example:

CREATE TABLE employees
AS (SELECT employee_id, last_name, first_name FROM existing_table)

Or you can use prepared statements, there are full working examples in a few languages in the QuestDB Postgres documentation, here is a snippet from the Python example:

# insert 10 records
for x in range(10):
  cursor.execute("""
    INSERT INTO example_table
    VALUES (%s, %s, %s);
    """, (dt.datetime.utcnow(), "python example", x))
# commit records
connection.commit()

Or you can bulk import from CSV, i.e.:

curl -F [email protected] http://localhost:9000/imp
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.