You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-23Lines changed: 42 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,22 @@
1
-
# [Example WASI proposal]
2
-
3
-
This template can be used to start a new proposal, which can then be proposed in the WASI Subgroup meetings.
4
-
5
-
The sections below are recommended. However, every proposal is different, and the community can help you flesh out the proposal, so don't block on having something filled in for each one of them.
6
-
7
-
Thank you to the W3C Privacy CG for the [inspiration](https://github.com/privacycg/template)!
8
-
9
-
# [Title]
1
+
# `wasi-sql`
10
2
11
3
A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API.
12
4
13
5
### Current Phase
14
6
15
-
[Fill in the current phase, e.g. Phase 1]
7
+
`wasi-messaging` is currently in [Phase 1](https://github.com/WebAssembly/WASI/blob/main/Proposals.md#phase-1---feature-proposal-cg).
`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.
26
18
27
-
## Table of Contents[if the explainer is longer than one printed page]
19
+
## Table of Contents
28
20
29
21
-[Introduction](#introduction)
30
22
-[Goals [or Motivating Use Cases, or Scenarios]](#goals-or-motivating-use-cases-or-scenarios)
@@ -43,27 +35,54 @@ TODO before entering Phase 2.
43
35
44
36
### Introduction
45
37
46
-
[The "executive summary" or "abstract". Explain in a few sentences what the goals of the project are, and a brief overview of how the solution works. This should be no more than 1-2 paragraphs.]
38
+
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.
39
+
40
+
### Goals
47
41
48
-
### Goals [or Motivating Use Cases, or Scenarios]
42
+
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.
49
43
50
-
[What is the end-user need which this project aims to address?]
44
+
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.
51
45
52
46
### Non-goals
53
47
54
-
[If there are "adjacent" goals which may appear to be in scope but aren't, enumerate them here. This section may be fleshed out as your design progresses and you encounter necessary technical and other trade-offs.]
48
+
- 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.
49
+
- 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.
50
+
- 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.
55
51
56
52
### API walk-through
57
53
58
54
[Walk through of how someone would use this API.]
59
55
60
-
#### [Use case 1]
56
+
#### Use case 1: Query data from a table
61
57
62
-
[Provide example code snippets and diagrams explaining how the API would be used to solve the given problem]
58
+
Imagine you have a WebAssembly program that needs to query data from a table in a SQL database. The following Rust code shows how you can use the `wasi-sql` interface to execute a SELECT statement and iterate over the resulting rows.
63
59
64
-
#### [Use case 2]
60
+
```rs
61
+
// Create a prepared statement
62
+
letstmt=sql::statement::prepare("SELECT * FROM users WHERE name = ? AND age = ?", vec!["John Doe", "32"])?;
65
63
66
-
[etc.]
64
+
// Execute the query and get the stream of rows
65
+
letresult_stream=sql::query(stmt)?;
66
+
67
+
// Iterate over the rows in the stream
68
+
forrowinresult_stream {
69
+
// Print the column names and values for the current row
70
+
println!("Column name: {:?}", row.field_name);
71
+
println!("Value: {:?}", row.value);
72
+
}
73
+
```
74
+
75
+
#### Use case 2: Insert data into a table
76
+
77
+
Imagine you have a WebAssembly program that needs to insert a row into a table in a SQL database. The following Rust code shows how you can use the wasi-sql interface to execute an INSERT statement.
0 commit comments