Query Language Snippets
All Snippets
SQL
Create
Insert multiple rows into a table.
INSERT INTO products (name, price) VALUES ('Banana', 0.99), ('Cherry', 2.99);
SQLAlchemy
Create
Create a SQLAlchemy engine and connect to a database.
from sqlalchemy import create_engine
engine = create_engine('sqlite:///example.db')
SQL
Create
Insert a single row into a table.
INSERT INTO products (name, price) VALUES ('Apple', 1.99);
GraphQL
Create
Mutation to create a new user.
mutation {
createUser(name: "Alice", email: "alice@example.com") {
id
name
}
}
SQLModel
Create
Define a SQLModel model.
from sqlmodel import SQLModel, Field
class User(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
name: str
age: int
Cypher
Create
Create a node with properties.
CREATE (n:Person {name: 'Alice', age: 32});
Cypher
Create
Create a relationship between nodes.
MATCH (a:Person), (b:Person)
WHERE a.name = 'Alice' AND b.name = 'Bob'
CREATE (a)-[r:FRIENDS_WITH]->(b)
RETURN r;
Redis
Create
Set a key-value pair with expiration.
SET user:1:name "Alice" EX 3600
MongoDB
Create
Create an index for faster queries.
db.users.createIndex({ email: 1 }, { unique: true });
MongoDB
Create
Insert a single document.
db.users.insertOne({ name: "Alice", age: 28 });
GraphQL
Create
Mutation with variables for dynamic input.
mutation CreateUser($name: String!, $email: String!) {
createUser(name: $name, email: $email) {
id
name
}
}
MongoDB
Create
Insert multiple documents.
db.users.insertMany([
{ name: "Bob", age: 35 },
{ name: "Carol", age: 22 }
]);