Learn SQL

How to Write SQL in Any Programming Language

A developer’s guide to querying databases in Python, JavaScript, Java, Go, Rust, and more — with code samples, best libraries, and comparisons.

Sign up for the latest in how to write SQL from the Galaxy Team!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Curious how to write SQL in other languages?

Whether you're building a backend service, running analytics, or integrating with a production database, knowing how to write SQL from your favorite programming language is a critical skill for any developer.

While SQL is a powerful declarative language on its own, most applications need to run queries dynamically - from Python scripts, JavaScript/TypeScript backends, Go microservices, or Java apps. That’s where language-specific SQL tools come in: they help you connect, write, and run queries from code - safely and efficiently.

Depending on your stack and use case, you might choose between:
Raw SQL, for full control and transparency
A query builder, which provides abstraction with flexibility
An ORM (Object-Relational Mapper), which lets you work with database rows as native objects in your language

Each approach comes with tradeoffs. Raw SQL gives you complete freedom and performance, but can be verbose and error-prone. Query builders like knex.js or sqlx offer flexibility with fewer bugs. And ORMs like SQLAlchemy, Prisma, or GORM can speed up development but often abstract away important SQL details.

This directory made by the Galaxy team will show you how to:

🔍 Write SQL in Python using libraries like pandas, SQLAlchemy, and DuckDB
🧠 Discover SQL libraries for JavaScript like Prisma, Drizzle, and knex.js
⚙️ Compare the best SQL ORMs for Go like GORM and sqlc
⚖️ Understand the tradeoffs between raw SQL vs ORM vs query builder

SQL in Languages

Learn how to query SQL in any language!

Trusted by top engineers on high-velocity teams

Aryeo Logo
Assort Health
Curri
Rubie
Comulate
Truvideo Logo
Ourv0.1-alphais coming in May 2025.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Check out some other topics!

Common Errors

We've aggregated some of the most common errors we've seen in SQL to help teams fix them!

Check out
super common SQL errors!

Integrations

Take a look at which databases, tools, and platforms Galaxy's modern SQL tool integrates with :)

Check out
Galaxy's Integrations