Skip to main content
Start building applications on top of YugabyteDB using your favorite programming language. YugabyteDB provides PostgreSQL-compatible YSQL and Cassandra-compatible YCQL APIs for seamless integration with your applications.

Quick Start

Building applications with YugabyteDB is straightforward. Choose your preferred programming language and get started in minutes.

Prerequisites

Before you begin:
  • YugabyteDB cluster: Set up a local cluster or create a free cluster on YugabyteDB Aeon
  • Programming language: Install your preferred language runtime (Java, Python, Node.js, etc.)
  • Driver: Install the appropriate database driver for your language

Choose Your Language

YugabyteDB supports drivers and ORMs for all major programming languages:

Java

PostgreSQL JDBC driver and YugabyteDB Smart Driver

Python

Psycopg2, Psycopg3, and SQLAlchemy support

Node.js

node-postgres driver with full async/await support

Go

pgx and GORM for efficient Go applications

C#

Npgsql driver and Entity Framework support

Ruby

pg gem and Active Record ORM

Basic Application Pattern

Here’s the typical workflow for building a YugabyteDB application:

1. Connect to the Database

Establish a connection using your driver with connection parameters.
import java.sql.Connection;
import java.sql.DriverManager;

String jdbcUrl = "jdbc:postgresql://localhost:5433/yugabyte";
Connection conn = DriverManager.getConnection(
    jdbcUrl, 
    "yugabyte", 
    "yugabyte"
);

2. Create Tables

Define your schema using standard SQL DDL statements.
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username TEXT NOT NULL,
    email TEXT UNIQUE NOT NULL,
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_users_email ON users(email);

3. Insert Data

Add records to your tables using INSERT statements.
String insertSQL = "INSERT INTO users (username, email) VALUES (?, ?)";
PreparedStatement pstmt = conn.prepareStatement(insertSQL);
pstmt.setString(1, "john_doe");
pstmt.setString(2, "[email protected]");
pstmt.executeUpdate();

4. Query Data

Retrieve data using SELECT statements.
String querySQL = "SELECT * FROM users WHERE email = ?";
PreparedStatement pstmt = conn.prepareStatement(querySQL);
pstmt.setString(1, "[email protected]");
ResultSet rs = pstmt.executeQuery();

while (rs.next()) {
    String username = rs.getString("username");
    System.out.println("User: " + username);
}

5. Update and Delete

Modify existing data as needed.
-- Update user information
UPDATE users SET username = 'jane_doe' WHERE email = '[email protected]';

-- Delete a user
DELETE FROM users WHERE email = '[email protected]';

Connection String Format

YugabyteDB uses PostgreSQL-compatible connection strings for YSQL:
jdbc:postgresql://hostname:port/database?user=username&password=password
postgresql://username:password@hostname:port/database
Common Parameters:
  • hostname: YugabyteDB server address (default: localhost)
  • port: YSQL port (default: 5433)
  • database: Database name (default: yugabyte)
  • user: Username (default: yugabyte)
  • password: User password (default: yugabyte)

SSL/TLS Connections

For secure connections, especially in production:
postgresql://username:password@hostname:port/database?ssl=true&sslmode=verify-full&sslrootcert=/path/to/root.crt

Application Best Practices

Connection pooling reduces overhead and improves performance by reusing database connections.Recommended poolers:
  • Java: HikariCP
  • Python: SQLAlchemy pooling
  • Node.js: pg-pool
  • Built-in: YSQL Connection Manager
Implement retry logic for transient errors in distributed systems:
  • Connection timeouts
  • Temporary network failures
  • Transaction conflicts
Use exponential backoff for retries.
Prepared statements provide:
  • Protection against SQL injection
  • Better query performance
  • Efficient parameterized queries
  • Use primary keys wisely for data distribution
  • Leverage indexes for query performance
  • Consider data locality for multi-region deployments

Sample Applications

YugabyteDB provides sample applications in multiple languages:
  • Java: JDBC examples with YugabyteDB
  • Python: Flask and Django applications
  • Node.js: Express.js REST APIs
  • Go: Microservices with pgx

View Sample Apps

Explore complete sample applications on GitHub

Next Steps

Drivers & ORMs

Learn about supported drivers and ORMs

YSQL API

Explore the YSQL API reference

Best Practices

Follow development best practices

Tutorials

Step-by-step application tutorials

Additional Resources

Build docs developers (and LLMs) love