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/hosted.sql
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,9 @@ select 'shell' as component,
10
10
SELECT'hero'as component,
11
11
'Hosted SQLPage'as title,
12
12
'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,
Copy file name to clipboardExpand all lines: examples/official-site/your-first-sql-website/index.sql
+33-14Lines changed: 33 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ select 'shell' as component,
12
12
'Poppins'as font;
13
13
14
14
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,
'Afraid of the setup ? Do it the easy way !'as title,
@@ -40,6 +40,7 @@ Building your website locally
40
40
=============================
41
41
42
42
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.
43
44
44
45
Open the file you downloaded above, and place `sqlpage.bin` (if you are on linux or Mac OS)
45
46
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
55
56
Your website’s first SQL file
56
57
=============================
57
58
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/)).
59
61
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.
61
64
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:
63
66
64
67
```sql
65
68
SELECT ''list'' AS component, ''Popular websites'' AS title;
66
69
67
70
SELECT ''Hello'' AS title, ''world'' AS description, ''https://wikipedia.org'' AS link;
68
71
```
69
72
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).
71
77
72
78
Your database schema
73
79
====================
74
80
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.
80
96
81
97
For our first website, let''s create a file located in `sqlpage/migrations/0001_create_users_table.sql` with the following contents:
82
98
@@ -88,7 +104,10 @@ Connect to a custom database
88
104
============================
89
105
90
106
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`.
0 commit comments