Connect your applications with supported drivers and ORMs
Applications connect to and interact with YugabyteDB using API client libraries (also known as drivers). YugabyteDB supports both PostgreSQL-compatible drivers for YSQL and Cassandra-compatible drivers for YCQL.
Because YugabyteDB YSQL is PostgreSQL-compatible, you can use standard PostgreSQL drivers to connect and work with YugabyteDB. These drivers provide full compatibility with PostgreSQL applications.
using Npgsql;string connString = "Host=localhost;Port=5433;Username=yugabyte;Password=yugabyte;Database=yugabyte";using (var conn = new NpgsqlConnection(connString)){ conn.Open(); using (var cmd = new NpgsqlCommand("SELECT username FROM users WHERE id = @id", conn)) { cmd.Parameters.AddWithValue("id", 1); var username = cmd.ExecuteScalar(); Console.WriteLine(username); }}
Connection pooling is essential for production applications:
Java - HikariCP
HikariConfig config = new HikariConfig();config.setJdbcUrl("jdbc:postgresql://localhost:5433/yugabyte");config.setUsername("yugabyte");config.setPassword("yugabyte");config.setMaximumPoolSize(10);HikariDataSource ds = new HikariDataSource(config);
Python - SQLAlchemy
from sqlalchemy import create_engineengine = create_engine( 'postgresql://yugabyte:yugabyte@localhost:5433/yugabyte', pool_size=10, max_overflow=20)
Node.js - pg-pool
const { Pool } = require('pg');const pool = new Pool({ max: 20, idleTimeoutMillis: 30000, connectionTimeoutMillis: 2000,});
YSQL Connection Manager
YugabyteDB includes a built-in connection pooler that provides connection pooling without external dependencies.Enable it on the server side for automatic connection management.