mirror of
https://github.com/actix/examples
synced 2025-06-28 18:00:37 +02:00
added async_pg example
This commit is contained in:
3
async_pg/sql/add_user.sql
Normal file
3
async_pg/sql/add_user.sql
Normal file
@ -0,0 +1,3 @@
|
||||
INSERT INTO testing.users(email, first_name, last_name, username)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING $table_fields;
|
3
async_pg/sql/create_db.sh
Executable file
3
async_pg/sql/create_db.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
psql -U postgres -h 127.0.0.1 -f setup_db_and_user.sql
|
1
async_pg/sql/get_users.sql
Normal file
1
async_pg/sql/get_users.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT $table_fields FROM testing.users;
|
20
async_pg/sql/setup_db_and_user.sql
Normal file
20
async_pg/sql/setup_db_and_user.sql
Normal file
@ -0,0 +1,20 @@
|
||||
DROP DATABASE IF EXISTS testing_db;
|
||||
|
||||
CREATE USER test_user WITH PASSWORD 'testing';
|
||||
|
||||
CREATE DATABASE testing_db OWNER test_user;
|
||||
|
||||
\connect testing_db;
|
||||
|
||||
DROP SCHEMA IF EXISTS testing CASCADE;
|
||||
CREATE SCHEMA testing;
|
||||
|
||||
|
||||
CREATE TABLE testing.users (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
email VARCHAR(200) NOT NULL,
|
||||
first_name VARCHAR(200) NOT NULL,
|
||||
last_name VARCHAR(200) NOT NULL,
|
||||
username VARCHAR(50) UNIQUE NOT NULL,
|
||||
UNIQUE (username)
|
||||
);
|
Reference in New Issue
Block a user