lispEn 2022-10-13 11:27:17

SQL queries and S-SQL

S-SQL provides a lispy syntax for SQL queries, and knows how to convert various lisp types to their textual SQL representation.

S-Expression = symbolic expression.

S-SQL = symbolic expression Structured Query Language.

An example:

(query (:select '* :from 'students))

SQL queries = Structured Query Language.

An example:

my_database=# select * from students;


Postmodern is a Common Lisp library for interacting with PostgreSQL databases.
see for more information: http://marijnhaverbeke.nl/postmodern/#quickstart

First we are going to create the user and  database into postgresql:

postgres=#
create user my_user with password 'ultra-secret-password';

CREATE ROLE

postgres=# create database my_database owner my_user ;

CREATE DATABASE


Now we need to load the library by quicklisp:


(ql:quickload "postmodern")
To load "postmodern":
 Load 1 ASDF system:
 postmodern
; Loading "postmodern"
("postmodern")

;; Use the package
(in-package :postmodern)
POMO> 

You can get the example


Test the connection


Create the table


Select SQL

Update SQL

#lisp #postgresql #postmodern


References:

https://github.com/marijnh/Postmodern#quickstart

https://www.postgresql.org/about/news/postgresql-15-released-2526/

https://www.postgresql.org/download/linux/debian/

#postgresql #postmodern






También te puede interesar
lisp codeEn 2022-07-13 13:12:00