Skip to content

Commit ced8610

Browse files
committed
update tutorial
1 parent e819872 commit ced8610

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

examples/official-site/your-first-sql-website/hosted.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ select 'shell' as component,
1010
SELECT 'hero' as component,
1111
'Hosted SQLPage' as title,
1212
'Work In Progress: We are working on a cloud version of SQLPage
13-
that will enable you to effortlessly set up your website online without the need to download any software or configure your own server.' as description,
13+
that will enable you to effortlessly set up your website online without the need to download any software or configure your own server.
14+
15+
In the meantime, you can already [try SQLPage online on repl.it](https://replit.com/@pimaj62145/SQLPage#index.sql)' as description,
1416
'https://upload.wikimedia.org/wikipedia/commons/thumb/9/94/Baustelle_H%C3%B6lzla_6066312.jpg/1024px-Baustelle_H%C3%B6lzla_6066312.jpg' as image,
1517
'https://forms.gle/z1qmuCwdNT5Am7gp6' as link,
1618
'Get notified when we are ready' as link_text;

examples/official-site/your-first-sql-website/index.sql

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ select 'shell' as component,
1212
'Poppins' as font;
1313

1414
SELECT 'hero' as component,
15-
'Building your first SQL Website' as title,
16-
'Let''s create your first website entirely in SQL together, step by step, from downloading SQLPage to making your site available online for everyone to browse.' as description,
15+
'Your first SQL Website' as title,
16+
'Let''s create your first website in SQL together, from downloading SQLPage to publishing your site online.' as description,
1717
'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Backlit_keyboard.jpg/1024px-Backlit_keyboard.jpg' as image,
18-
'mailto:contact@ophir.dev' as link,
19-
'Instructions unclear ? Get in touch !' as link_text;
18+
'https://replit.com/@pimaj62145/SQLPage#index.sql' as link,
19+
'Follow this tutorial online' as link_text;
2020

2121
SELECT 'alert' as component,
2222
'Afraid of the setup ? Do it the easy way !' as title,
@@ -40,6 +40,7 @@ Building your website locally
4040
=============================
4141
4242
Create a folder on your computer where you will store all contents related to your sql website.
43+
In the rest of this tutorial, we will call this folder the **root folder** of your website.
4344
4445
Open the file you downloaded above, and place `sqlpage.bin` (if you are on linux or Mac OS)
4546
or `sqlpage.exe` at the root of the folder.
@@ -55,28 +56,43 @@ You can open your website locally by visiting [`http://localhost:8080`](http://l
5556
Your website’s first SQL file
5657
=============================
5758
58-
In the root folder of your SQLPage website, create a new SQL file called `index.sql`. Open it in a text editor.
59+
In the root folder of your SQLPage website, create a new SQL file called `index.sql`.
60+
Open it in a text editor that supports SQL syntax highlighting (I recommend [VSCode](https://code.visualstudio.com/)).
5961
60-
The `index.sql` file will be executed when you open the root of your website. You can use it to retrieve data from your database and define how it should be displayed on your website.
62+
The `index.sql` file will be executed every time a visitor opens your website''s home page.
63+
You can use it to retrieve data from your database and define how it should be displayed to your visitors.
6164
62-
As an example, let''s start with a simple SQL code that displays a list of popular websites:
65+
As an example, let''s start with a simple `index.sql` that displays a list of popular websites:
6366
6467
```sql
6568
SELECT ''list'' AS component, ''Popular websites'' AS title;
6669
6770
SELECT ''Hello'' AS title, ''world'' AS description, ''https://wikipedia.org'' AS link;
6871
```
6972
70-
The list of components you can use and their properties is available in [SQLPage''s online documentation](https://sql.ophir.dev/documentation.sql).
73+
The first line of the file defines the component that will be used to display the data, and properties of that component.
74+
In this case, we use the [`list` component](/documentation.sql?component=list#component) to display a list of items.
75+
The second line defines the data that will populate the component.
76+
All the components you can use and their properties are documented in [SQLPage''s online documentation](https://sql.ophir.dev/documentation.sql).
7177
7278
Your database schema
7379
====================
7480
75-
The database schema for your SQLPage website can be defined using SQL scripts located in the **`sqlpage/migrations`** subdirectory of your website''s root folder.
76-
Each script represents a migration that sets up or modifies the database structure.
77-
The scripts are executed in alphabetical order, so you can prefix them with a number to control the order in which they are executed.
78-
If you don''t want SQLPage to manage your database schema, you can ignore the `sqlpage/migrations` folder completely,
79-
and manually create and update database tables using your own favorite tools.
81+
> If you already have a database populated with data,
82+
> or if you intend to use other tools to manage your database schema,
83+
> you can skip this section.
84+
85+
The database schema for your SQLPage website can be defined using SQL scripts located in the
86+
**`sqlpage/migrations`** subdirectory of your website''s root folder.
87+
Each script represents a [migration](https://en.wikipedia.org/wiki/Schema_migration)
88+
that sets up or modifies the database structure.
89+
90+
The scripts are executed in order. You must prefix them with a number to control the order in which they are executed.
91+
For instance, `mywebsite/sqlpage/migrations/0001_create_users_table.sql`
92+
will be executed before `mywebsite/sqlpage/migrations/0002_add_email_to_users_table.sql`.
93+
SQLPage keeps track of which migrations have already run
94+
(by storing the executed migrations in a table named `_sqlx_migrations`),
95+
and will only execute new migrations.
8096
8197
For our first website, let''s create a file located in `sqlpage/migrations/0001_create_users_table.sql` with the following contents:
8298
@@ -88,7 +104,10 @@ Connect to a custom database
88104
============================
89105
90106
By default, SQLPage uses a [SQLite](https://www.sqlite.org/about.html) database stored in a file named `sqlpage.db` in your website''s root folder.
91-
You can change this by creating a file named `sqlpage/sqlpage.json` in your website''s root folder with the following contents:
107+
You can change this by creating a file named `sqlpage.json` in a folder called `sqlpage`.
108+
So, if your website''s root folder is `/mysite`, you should create a file at `/mysite/sqlpage/sqlpage.json`.
109+
110+
Here is an example `sqlpage.json` file:
92111
93112
```sql
94113
{ "database_url": "sqlite://:memory:" }

0 commit comments

Comments
 (0)