INSERT & BULK INSERT
Insert single rows with INSERT INTO or multiple rows efficiently with BULK INSERT INTO. For tables with embedding columns, vectors are computed automatically.
INSERT Syntax
INSERT INTO table_name (col1, col2, ...) VALUES (val1, val2, ...);Returns the number of rows inserted (1 for a single INSERT).
INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com');
INSERT INTO users (id, name, email) VALUES (2, 'Bob', 'bob@example.com');BULK INSERT
BULK INSERT is an AuroraSQL extension for inserting multiple rows in a single statement. It is significantly faster than multiple individual INSERTs because it batches WAL writes and embedding requests.
BULK INSERT INTO table_name (col1, col2, ...) VALUES
(val1, val2, ...),
(val3, val4, ...),
(val5, val6, ...);BULK INSERT INTO users (id, name, email, age) VALUES
(3, 'Charlie', 'charlie@example.com', 35),
(4, 'Diana', 'diana@example.com', 28),
(5, 'Eve', 'eve@example.com', 42);Tip
Automatic Embeddings
For tables with EMBEDDING MODEL columns, embeddings are computed automatically on INSERT. You provide the text value; GalaxDB handles the rest.
CREATE TABLE docs (
id INT PRIMARY KEY,
body TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384
);
-- Just insert the text — embedding computed automatically
INSERT INTO docs (id, body) VALUES (1, 'machine learning and neural networks');
INSERT INTO docs (id, body) VALUES (2, 'cooking recipes italian pasta');
-- BULK INSERT also computes embeddings automatically
BULK INSERT INTO docs (id, body) VALUES
(3, 'rust programming language systems'),
(4, 'deep learning transformers attention'),
(5, 'database storage engine LSM tree');The embedding computation is asynchronous — the INSERT returns immediately after the row is written to the WAL. The sidecar processes the embedding queue in the background. For SEMANTIC_MATCH queries, rows with pending embeddings are excluded until their embeddings are computed.
Examples
Insert with all column types
CREATE TABLE products (
id INT PRIMARY KEY,
name TEXT NOT NULL,
price FLOAT,
in_stock BOOL,
sku TEXT
);
INSERT INTO products (id, name, price, in_stock, sku)
VALUES (1, 'Widget Pro', 29.99, true, 'WGT-001');Python client INSERT
import galaxdb
db = galaxdb.Database("./data")
# Single insert — returns row count (int)
count = db.execute("INSERT INTO docs (id, body) VALUES (1, 'hello world')")
print(count) # 1
# Bulk insert
count = db.execute("""
BULK INSERT INTO docs (id, body) VALUES
(2, 'machine learning'),
(3, 'deep learning'),
(4, 'natural language processing')
""")
print(count) # 3psycopg2 parameterized INSERT
import psycopg2
conn = psycopg2.connect(host="localhost", port=5433, dbname="galaxdb", sslmode="disable")
cur = conn.cursor()
# Parameterized insert (safe against SQL injection)
cur.execute(
"INSERT INTO docs (id, body) VALUES (%s, %s)",
(1, "machine learning and neural networks")
)
conn.commit()