From b4094e99de6dfb18000bfe03445f277548fd1431 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Sat, 3 Feb 2024 14:38:04 -0500 Subject: [PATCH] Update README.md --- README.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c76cdb4..baf60ca 100644 --- a/README.md +++ b/README.md @@ -71,26 +71,35 @@ See the [API documentation](https://ose-net.github.io/yesql.net/api/YeSql.Net.ht Create a file with **.sql** extension containing the SQL statements. -**Example:** +> It is recommended that the **extension be lowercase** so that there are no problems when loading the SQL file on a Linux distro. + +**Example:** `users.sql` ```sql -- name: GetUsers --- Gets user information. +-- Gets all users SELECT id, username, email FROM users; --- name: GetRoles --- Gets role information. +-- name: GetUserById +-- Gets user information SELECT -id, -name -FROM roles; +id, +username, +email +FROM users +WHERE id = @id; + +-- name: InsertUser +-- Create user record +INSERT INTO users (id, username, email) +VALUES (@id, @username, @email); ``` Each SQL statement must be associated with a tag using the `name:` prefix and must begin with a comment. This is necessary so that the parser can uniquely identify each SQL statement by its tag. -For example, in this case the tag is `GetRoles` and the SQL statement would be `SELECT id, name FROM roles;`. +For example, in this case the tag is `GetUsers` and the SQL statement would be `SELECT id, username, email FROM users;`. You should also note that comments that do not use the `name:` prefix will be ignored by the parser. @@ -120,6 +129,8 @@ string sqlCode = sqlStatements[tagName]; ``` But you must specify the tag name to access the SQL statement. Remember that each SQL code is identified with its respective tag. +> The tag name is case-sensitive. `GetUsers` is not the same as `getUsers`. + ### Load from a set of directories You can load SQL statements from all the SQL files in the specified directories.