This is an example showcasing the use of Spin PostgreSQL bindings within a guest component.
Run the following commands to setup a virtual environment with Python.
python3 -m venv venv
source venv/bin/activateInstall the required packages specified in the requirements.txt using the command:
pip3 install -r requirements.txtFor this example, a PostgreSQL database named spin_dev must be accessible at 127.0.0.1 with a user postgres should exist.
Create a test table in your PostgreSQL database:
CREATE TABLE test (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
value INTEGER
);
INSERT INTO test (name, value) VALUES
('foo', 42),
('bar', 100);spin build --up$ curl localhost:3000
id | name | value
-----------------
1 | foo | 42
2 | bar | 100