Database
Every DYPAI project includes a dedicated PostgreSQL database with three management interfaces: a visual table editor, a full SQL console, and automatically generated REST endpoints for every table.
Overview
When you create a DYPAI project, a dedicated PostgreSQL 15 instance is provisioned exclusively for that project. No data is shared between projects. You interact with your database through three complementary interfaces:
- Visual Editor β create tables, define columns, and configure constraints without writing SQL.
- SQL Editor β run arbitrary SQL queries in a Monaco-powered console with syntax highlighting and result export.
- Automatic REST API β every table is exposed as a set of CRUD endpoints you can call from any client.
In addition, DYPAI provides Row Level Security (RLS) for fine-grained access control and automatic backups so your data is always recoverable.
Visual Editor
The Visual Editor lets you create and modify tables through a graphical interface. Open the Database section in your project dashboard and click New Table to get started.
- Enter a table name. DYPAI enforces
snake_casenaming by default. - Add columns by clicking Add Column. For each column you can configure:
- Name and data type
- Default value (static or expression such as
now()) - Nullable / Not Null constraint
- Unique constraint
- A primary key column named
idof typeuuidwith a default ofgen_random_uuid()is added automatically. You can change it toint8with auto-increment if you prefer sequential IDs. - Optionally enable Row Level Security during table creation. You can also enable it later.
- Click Save. DYPAI runs the corresponding
CREATE TABLEstatement and immediately generates REST endpoints.
After creation, use the Visual Editor to add or remove columns, create indexes, and define foreign-key relationships between tables by dragging connections in the schema diagram.
SQL Editor
The SQL Editor is a Monaco-based console embedded in the dashboard. It supports full PostgreSQL syntax with auto-completion for table names, column names, and built-in functions.
-- Example: find active users created in the last 7 days
SELECT id, email, created_at
FROM users
WHERE is_active = true
AND created_at > now() - interval '7 days'
ORDER BY created_at DESC;Key features of the SQL Editor:
- Query execution β press Ctrl+Enter (or Cmd+Enter on macOS) to run the current query. Results render in a scrollable data grid below the editor.
- Multiple statements β separate statements with semicolons. Use Ctrl+Shift+Enter to run all statements sequentially.
- Export to CSV β click the download icon above the result grid to export the current result set as a
.csvfile. - Query history β the last 50 queries are saved per project and accessible from the history panel.
Automatic REST API
Every table you create is instantly available through auto-generated REST endpoints. No configuration is required β the endpoints follow a predictable pattern based on your table name.
https://<project-ref>.dypai.ai/api/<table_name>. They support filtering, pagination, ordering, and field selection through query parameters.For example, if you have a products table, you can fetch all products with a simple GET request:
const response = await fetch(
'https://my-project.dypai.ai/api/products?select=id,name,price&order=price.asc&limit=20',
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
}
)
const { data, count } = await response.json()
console.log(data) // [{ id: "...", name: "Widget", price: 9.99 }, ...]See the API Builder documentation for the complete list of supported query parameters and operators.
Row Level Security
Row Level Security (RLS) lets you define policies that control which rows a user can access. When RLS is enabled on a table, every query β including those from the auto-generated REST API β is filtered through your policies.
-- Allow users to read only their own rows
CREATE POLICY "Users can view own data"
ON profiles
FOR SELECT
USING (auth.uid() = user_id);
-- Allow users to insert rows with their own user_id
CREATE POLICY "Users can insert own data"
ON profiles
FOR INSERT
WITH CHECK (auth.uid() = user_id);Enable RLS on any table from the Visual Editor by toggling Enable Row Level Security, or by running ALTER TABLE table_name ENABLE ROW LEVEL SECURITY; in the SQL Editor.
Data Types
DYPAI supports all standard PostgreSQL data types. The table below lists the most commonly used types available in the Visual Editor:
| Type | Alias | Description |
|---|---|---|
text | β | Variable-length character string with no limit |
varchar(n) | character varying | Variable-length string with a maximum of n characters |
int4 | integer | 32-bit signed integer (-2,147,483,648 to 2,147,483,647) |
int8 | bigint | 64-bit signed integer |
float4 | real | 32-bit floating-point number |
float8 | double precision | 64-bit floating-point number |
numeric | decimal | Exact numeric with selectable precision, ideal for monetary values |
bool | boolean | True or false |
timestamp | β | Date and time without time zone |
timestamptz | timestamp with time zone | Date and time with time zone (recommended over timestamp) |
date | β | Calendar date (year, month, day) |
jsonb | β | Binary JSON with indexing support |
uuid | β | Universally unique identifier (128-bit) |
text[] | β | Array of text values |
int4[] | integer[] | Array of 32-bit integers |
jsonb[] | β | Array of JSONB objects |
You can also use any PostgreSQL type directly in the SQL Editor, including composite types, enums, and domain types.
Backups
DYPAI automatically creates daily backups of your database. You can also trigger a manual backup at any time from the Settings > Backups section of your project dashboard.
| Plan | Automatic Backups | Retention | Manual Backups |
|---|---|---|---|
| Free | Daily | 7 days | 1 |
| Pro | Daily | 30 days | 5 |
| Enterprise | Hourly | 90 days | Unlimited |
To restore from a backup, select the desired snapshot in the Backups panel and click Restore. The restore process replaces the current database state with the backup contents. A pre-restore snapshot is created automatically so you can roll back if needed.