---
title: 'This week in #dev (Aug 23, 2024)'
teaser: 'Using constraints in Postgres and querying LLMs in the terminal.

  '
tags: this week in dev,til,postgresql,large language models
author: thoughtbot
published_on: 2024-09-02
---

Welcome to another edition of [This Week in #dev](https://thoughtbot.com/blog/tags/this-week-in-dev),
a series of posts where we bring some of our most interesting Slack
conversations to the public.

## Managing uniqueness in Postgres with constraints

[Joël Quenneville][joelq] learned that PostgreSQL enables the management of
uniqueness through constraints instead of manually creating indexes. He notes
that older documentation even suggests that using constraints is preferable to
using indexes.

```sql
CREATE TABLE products (
    product_no integer UNIQUE,
    name text,
    price numeric
);
```

[joelq]: https://thoughtbot.com/blog/authors/joel-quenneville

## LLMs answering questions in your terminal

[Matheus Richard][matheus] shares that he created a small script to send a
question to an LLM (OpenAI's GPT-4-mini in this case) in the terminal. [Jimmy
Thigpen][jimmy] chimes in and says that he has a similar script that uses the
[`llm` CLI tool] and [Ollama] running locally:

```sh
#!/bin/sh

llm -s "Answer in as few words as possible. Use a brief style with short replies." -m llama3.1 "$*"
```

Usage:

```sh
$ ask how to stop all docker containers
docker stop $(docker ps -q)
```

[`llm` CLI tool]: https://github.com/simonw/llm
[ollama]: https://ollama.com/
[jimmy]: https://thoughtbot.com/blog/authors/jimmy-thigpen
[matheus]: https://thoughtbot.com/blog/authors/matheus-richard

## Thanks

This edition was brought to you by [Jimmy Thigpen][jimmy], [Joël Quenneville][joelq], and [Matheus Richard][matheus]. Thanks to all contributors! 🎉
