Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
docs
Commits
44483b0a
Commit
44483b0a
authored
1 year ago
by
Alexander Tolstoy
Committed by
Yaroslav Dynnikov
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix parametrized queries examples
parent
5f979757
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!209
fix parametrized queries examples
Pipeline
#28076
passed
1 year ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/reference/sql_queries.md
+5
-6
5 additions, 6 deletions
docs/reference/sql_queries.md
docs/tutorial/sql_examples.md
+7
-6
7 additions, 6 deletions
docs/tutorial/sql_examples.md
with
12 additions
and
12 deletions
docs/reference/sql_queries.md
+
5
−
6
View file @
44483b0a
...
...
@@ -66,8 +66,7 @@ Picodata при работе с распределенной СУБД.
В этом случае SQL-запрос должен передаваться в качестве содержимого
функции
`pico.sql()`
. Тело запроса следует указать внутри скобок. Для
языка Lua обязательно использование блока фигурных скобок после запроса.
Внутри фигурных скобок опционально указываются параметры значений:
языка Lua внутри фигурных скобок опционально указываются параметры значений:
```
"запрос", {значения передаваемых параметров}
...
...
@@ -81,11 +80,11 @@ Picodata при работе с распределенной СУБД.
[[запрос]], {значения передаваемых параметров}
```
Если передаваемых параметров нет,
содержимое
фигурных скобок
остается
пустым. Пример команды:
Если передаваемых параметров нет,
блок
фигурных скобок
можно оставить
пустым
или не указывать его совсем
. Пример команды:
```
lua
pico
.
sql
(
[[select * from "characters"]]
,
{}
)
pico
.
sql
(
[[select * from "characters"]]
)
```
Далее приведены команды с объяснением их действия. Для большинства
примеров используется язык консоли SQL кроме тех случаев, когда
...
...
@@ -251,7 +250,7 @@ _Примечание_: строки в выводе идут в том поря
команды дадут одинаковый результат (вывод строки по известному `id`). :
```
sql
select "name" from "characters" where "id" = 1
;
select "name" from "characters" where "id" = 1;
```
```
lua
...
...
This diff is collapsed.
Click to expand it.
docs/tutorial/sql_examples.md
+
7
−
6
View file @
44483b0a
...
...
@@ -62,8 +62,7 @@ pico.sql([[
```
sql
pico
.
sql
(
[[
insert
into
"friends_of_peppa"
(
"id"
,
"name"
)
values
(
?
,
?
)]],
{
1
,
"Suzy"
}
[[
insert
into
"friends_of_peppa"
(
"id"
,
"name"
)
values
(
1
,
"Suzy"
)]]
)
```
...
...
@@ -71,22 +70,24 @@ pico.sql(
```
sql
pico
.
sql
(
[[
insert
into
"friends_of_peppa"
(
"id"
,
"name"
)
values
(
1
,
"Suzy"
)]],{}
[[
insert
into
"friends_of_peppa"
(
"id"
,
"name"
)
values
(
?
,
?
)]],
{
1
,
"Suzy"
}
)
```
См.
[
подробнее
](
../reference/sql_queries.md#insert
)
о различиях в
`INSERT`
-запросах.
## Чтение данных из таблицы {: #reading-from-table }
Для чтения всех данных из таблицы подойдёт команда:
```
pico.sql([[select * from "friends_of_peppa"]]
, {}
)
pico.sql([[select * from "friends_of_peppa"]])
```
Можно вывести отдельно строку по известному полю:
```
pico.sql([[select * from "friends_of_peppa" where "id" = 1]]
, {}
)
pico.sql([[select * from "friends_of_peppa" where "id" = 1]])
```
См.
[
подробнее
](
../reference/sql_queries.md#select
)
о вариантах чтения данных в SQL.
...
...
@@ -96,7 +97,7 @@ pico.sql([[select * from "friends_of_peppa" where "id" = 1]], {})
Удаление строки с известным
`id`
:
```
sql
picodata
>
pico
.
sql
([[
delete
from
"friends_of_peppa"
where
"id"
=
1
]]
,
{}
)
picodata
>
pico
.
sql
([[
delete
from
"friends_of_peppa"
where
"id"
=
1
]])
```
В консоли будет выведено количество удаленных строк (в данном случае, это
`1`
).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment