├── .github └── workflows │ └── main.yml ├── .gitignore ├── README.md ├── imports.md └── wit ├── readwrite.wit ├── sql.wit └── types.wit /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [main] 5 | pull_request: 6 | branches: [main] 7 | 8 | jobs: 9 | abi-up-to-date: 10 | name: Check ABI files are up-to-date 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: WebAssembly/wit-abi-up-to-date@v17 15 | with: 16 | wit-bindgen: '0.18.0' 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/wasi-sql/d14174a2a03da5cb0985e662d9d0193afe1fae17/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `wasi-sql` 2 | 3 | A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API. 4 | 5 | ### Current Phase 6 | 7 | `wasi-sql` is currently in [Phase 1](https://github.com/WebAssembly/WASI/blob/main/Proposals.md#phase-1---feature-proposal-cg). 8 | 9 | ### Champions 10 | 11 | - [Dan Chiarlone](https://github.com/danbugs) 12 | - [David Justice](https://github.com/devigned) 13 | - [Jiaxiao Zhou](https://github.com/Mossaka) 14 | 15 | ### Phase 4 Advancement Criteria 16 | 17 | `wasi-sql` should have at least two implementations (i.e., from service providers, and or cloud providers), and, at the very minimum, pass the testsuite for Windows, Linux, and MacOS. 18 | 19 | ## Table of Contents 20 | 21 | - [Introduction](#introduction) 22 | - [Goals [or Motivating Use Cases, or Scenarios]](#goals-or-motivating-use-cases-or-scenarios) 23 | - [Non-goals](#non-goals) 24 | 25 | ### Introduction 26 | 27 | The `wasi-sql` interface allows WebAssembly programs to interact with SQL databases in a generic and safe way. It provides functions for querying and modifying data, using prepared statements and handling errors. The interface is flexible and consistent, supporting various SQL flavors. 28 | 29 | ### Goals 30 | 31 | The `wasi-sql` interface aims to provide a consistent and easy-to-use way for WebAssembly programs to access and manipulate data stored in SQL databases. It targets the features commonly used by 80% of user applications. By focusing on commonly used features, the interface aims to provide a simple and reliable way to build stateful services that access SQL databases. 32 | 33 | The `wasi-sql` interface abstracts away specific SQL flavors and database APIs, allowing WebAssembly programs to be portable across different SQL databases that support the interface. It also abstracts away the network stack, allowing WebAssembly programs to access SQL databases without worrying about the specific network protocol used. This allows users to focus on building their applications, rather than communication details with the database. 34 | 35 | ### Non-goals 36 | 37 | - The `wasi-sql` interface does not aim to provide support for every possible feature of SQL databases. Instead, it focuses on the features that are commonly used by 80% of user applications. 38 | - The `wasi-sql` interface does not aim to provide support for specific database APIs or network protocols. It abstracts away these implementation details to allow WebAssembly programs to be portable across different SQL databases that support the interface. 39 | - The `wasi-sql` interface does not aim to address control-plane behavior or functionality, such as cluster management, monitoring, data consistency, replication, or sharding. These are provider-specific and are not specified by the wasi-sql interface. 40 | 41 | ### API walk-through 42 | 43 | For a full API walk-through, see [wasi-sql-demo](https://github.com/danbugs/wasi-sql-demo). 44 | 45 | > Note: This README needs to be expanded to cover a number of additional fields suggested in the 46 | [WASI Proposal template](https://github.com/WebAssembly/wasi-proposal-template). 47 | -------------------------------------------------------------------------------- /imports.md: -------------------------------------------------------------------------------- 1 |
wasi:sql/types@0.2.0-draft
wasi:sql/readwrite@0.2.0-draft
variant data-type
common data types
15 |int32
: s32
int64
: s64
uint32
: u32
uint64
: u64
float
: float64
double
: float64
str
: string
boolean
: bool
date
: string
time
: string
timestamp
: string
binary
: list<u8
>null
record row
one single row item
33 |field-name
: string
value
: data-type
resource statement
allows parameterized queries 40 | e.g., prepare("SELECT * FROM users WHERE name = ? AND age = ?", vec!["John Doe", "32"])
41 |resource error
An error resource type. 43 | Currently, this provides only one function to return a string representation 44 | of the error. In the future, this will be extended to provide more information.
45 |resource connection
[static]statement.prepare: func
query
: string
params
: list<string
>[method]error.trace: func
self
: borrow<error
>[static]connection.open: func
connection
>, own<error
>>type statement
82 | #### `type row` 83 | [`row`](#row) 84 |
85 | #### `type error` 86 | [`error`](#error) 87 |
88 | #### `type connection` 89 | [`connection`](#connection) 90 |
91 | ---- 92 |
query: func
query is optimized for querying data, and 95 | implementors can make use of that fact to optimize 96 | the performance of query execution (e.g., using 97 | indexes).
98 |c
: borrow<connection
>q
: borrow<statement
>exec: func
exec is for modifying data in the database.
109 |c
: borrow<connection
>q
: borrow<statement
>u32
, own<error
>>