Connect |> 

Database

Connect your application to the internet as a Postgres compatible database. Here’s an example using psycopg2 and Python.

  1. To get started, let’s install psycopg2.
$ pip install psycopg2
# Or if the above command runs into issues on your computer
$ pip install psycopg2-binary
  1. Run the following in Python. Be sure to grab an API key for authenticating to fill in the api_key string for the password when authenticating.
# The postgres adapter used to connect to LSD with
import psycopg2

# Setting up a connection to LSD via postgres
conn = psycopg2.connect("host='lsd.so' dbname='<your email>' password='api_key'")

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)

Related: