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: examples/official-site/your-first-sql-website/tutorial.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,18 @@
3
3
Create a folder on your computer where you will store all contents related to your sql website.
4
4
In the rest of this tutorial, we will call this folder the **root folder** of your website.
5
5
6
-
Open the file you downloaded above, and place `sqlpage.bin` (if you are on linux or Mac OS)
7
-
or `sqlpage.exe` at the root of the folder.
6
+
- On **Windows**, place the `sqlpage.exe` you downloaded above at the root of the folder. Then double-click the `sqlpage.exe` file to start the server.
7
+
- On **Linux**, place `sqlpage.bin` at the root of the folder. Then open a terminal, cd to the root folder of your website, and run `./sqlpage.bin` to start the server.
8
+
- On **Mac OS**, if you installed SQLPage using Homebrew, then you do not need to place anything at the root of the folder. Open Terminal, cd to the root folder of your website, and type `sqlpage` to start the server.
8
9
9
-
Then launch the `sqlpage.bin` executable file you just downloaded in a terminal from this folder.
10
-
11
-

10
+

12
11
13
12
You should see a message in your terminal that includes the sentence `accessible from the network, and locally on http://localhost:8080`
14
13
15
14
You can open your website locally by visiting [`http://localhost:8080`](http://localhost:8080)
16
15
16
+
SQLPage should have automatically created a folder called `sqlpage` with a SQLite database file named `sqlpage.db`. This is your website's default database - don't worry, we'll learn how to connect to other databases like PostgreSQL, MySQL, or SQL Server later!
17
+
17
18
# Your website’s first SQL file
18
19
19
20
In the root folder of your SQLPage website, create a new SQL file called `index.sql`.
@@ -81,13 +82,16 @@ If you then deploy your website online using a service like [DataPage.app](https
81
82
82
83
Later, when you want to deploy your website online, you can switch back to a persistent database like
83
84
84
-
- a SQLite file with `sqlite://your-database-file.db` ([see options](https://docs.rs/sqlx/0.6.3/sqlx/sqlite/struct.SqliteConnectOptions.html#main-content)),
85
-
- a PostgreSQL-compatible server with `postgres://user:password@host/database` ([see options](https://www.postgresql.org/docs/15/libpq-connect.html#id-1.7.3.8.3.6)),
86
-
- a MySQL-compatible server with `mysql://user:password@host/database` ([see options](https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html)),
87
-
- a Microsoft SQL Server with `mssql://user:password@host/database` ([see options](https://docs.rs/sqlx-oldapi/latest/sqlx_oldapi/mssql/struct.MssqlConnectOptions.html), [note about named instances](https://github.com/lovasoa/SQLpage/issues/92)),
85
+
- a SQLite file with `sqlite://your-database-file.db` ([see options](https://docs.rs/sqlx-oldapi/latest/sqlx_oldapi/sqlite/struct.SqliteConnectOptions.html)),
86
+
- a PostgreSQL-compatible server with `postgres://user:password@host/database` ([see options](https://docs.rs/sqlx-oldapi/latest/sqlx_oldapi/postgres/struct.PgConnectOptions.html)),
87
+
- a MySQL-compatible server with `mysql://user:password@host/database` ([see options](https://docs.rs/sqlx-oldapi/latest/sqlx_oldapi/mysql/struct.MySqlConnectOptions.html)),
88
+
- a Microsoft SQL Server with `mssql://user:password@host/database` ([see options](https://docs.rs/sqlx-oldapi/latest/sqlx_oldapi/mssql/struct.MssqlConnectOptions.html#method.from_str), [note about named instances](https://github.com/lovasoa/SQLpage/issues/92)),
89
+
90
+
> If `user` or `password`**contains special characters**, you should [**percent-encode**](https://en.wikipedia.org/wiki/Percent-encoding) them.
91
+
>
92
+
> For instance, a SQL Server database named `db` running on `localhost` port `1433` with the username `funny:user` and the password `p@ssw0rd` would be represented as
If `user` or `password` contains special characters, you should [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) them.
90
-
For instance, a SQL Server database named `db` running on `localhost` port `1433` with the username `funny:user` and the password `p@ssw0rd` would be represented as `mssql://funny%3Auser:p%40ssw0rd@localhost:1433/db`.
91
95
For more information about the properties that can be set in sqlpage.json, see [SQLPage's configuration documentation](https://github.com/lovasoa/SQLpage/blob/main/configuration.md#configuring-sqlpage)
92
96
93
97

@@ -103,7 +107,8 @@ SELECT 'form' AS component, 'Add a user' AS title;
103
107
SELECT'Username'as name, TRUE as required;
104
108
```
105
109
106
-
The snippet above uses the [`form` component](https://sql.datapage.app/documentation.sql?component=form#component) to display a form on your website.
110
+
The first SELECT statement opens the [`form` component](https://sql.datapage.app/component.sql?component=form).
111
+
The second SELECT statement adds a field to the form. Since we do not specify a `type`, it will be a text field. The label displayed above the field will be the same as its name by default.
107
112
108
113
### Handling form submission
109
114
@@ -160,7 +165,7 @@ Here is a screenshot of the final result:
160
165
161
166

162
167
163
-
To go further, have a look at [the examples section of our Github repository](https://github.com/lovasoa/SQLpage/tree/main/examples).
168
+
To go further, have a look at [the examples](../examples/).
0 commit comments