owned this note changed 5 years ago
Linked with GitHub

REST API in PostgreSQL - CHIN SHEN FANG

tags: COSCUP2020 中階 TR213

歡迎來到 https://hackmd.io/@coscup/2020 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

Postgrest intro

  • middle ware

  • 以 API 形式作服務

  • 用 Haskell 寫的

  • 以資料庫產生 API

安裝 Postgrest

  • 先安裝 PostgreSQL
  • github 上以編譯好的檔案

Init database

  • Create schema: api
  • Create table: api.todos (id serial primary kets)

Create role

Grant usage

設定檔

  • db-uri
    • 密碼可用 pgpass 儲存,增加安全性
  • db-schema="api"
  • db-anon-role="web_anon"

Running Postgres

  • ./postgrest tutorial.conf
  • Each service need one config
    • ./postgrest service1.conf
    • ./postgrest service2.conf

Example

Select a repo