# How to Write SQL

DevFeed: [How to Write SQL](<https://devfeed.tech/articles/how-to-write-sql-34558.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2017/06/how-to-write-sql/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2017-06-08T11:23:26Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Code](<https://devfeed.tech/topics/code.md>), [Python](<https://devfeed.tech/topics/python.md>), [Clojure](<https://devfeed.tech/topics/clojure.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [orm](<https://devfeed.tech/tags/orm.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [psql](<https://devfeed.tech/tags/psql.md>), [python](<https://devfeed.tech/tags/python.md>), [repl](<https://devfeed.tech/tags/repl.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

A tutorial on writing SQL as repository files rather than embedding queries as strings or relying entirely on an ORM. It discusses maintaining and debugging raw SQL, demonstrates a query against the Chinook database, and explains how psql variables can be used to run and edit queries interactively.

## Source excerpt

Kris Jenkins cooked up a very nice way to embed SQL in your code: YeSQL for Clojure. The main idea is that you should be writing your SQL queries in .sql files in your code repository and maintain them there. The idea is very good and it is now possible to find alternative implementations of the Clojure yesql library in other languages. Today, we are going to have a look at one of them for the python programming language: anosql.