Connect with psql

LSD (LSD SQL Database) is postgres-compatible meaning you can connect to our public instance like you would any Postgres database

$ psql -h lsd.so -U you

you=> SELECT title FROM https://lsd.so

Connect with a driver

You can also connect to LSD using a postgres driver; here's what that looks like in a Python application

First, install the psycopg2-binary package (in case you're curious why the "-binary" one)

$ pip install psycopg2-binary

Then, somewhere in your code

import psycopg2

conn = psycopg2.connect("dbname='you' host='lsd.so'")
with conn.cursor() as curs:
  curs.execute("""
    FROM https://news.ycombinator.com
    |> GROUP BY span.titleline
    |> SELECT a AS post
  """")
  rows = curs.fetchall()
  for row in rows:
    print(row)

Connect to our REST API

If you'd like to leverage LSD from a client-side application, you can make a request to our /api endpoint with your code in the query query parameter

fetch(
  `https://lsd.so/api?query=${
    encodeURIComponent(
      "SELECT title FROM https://lsd.so"
    )
  }`
);