Update README.md

This commit is contained in:
Григорий Сафронов 2025-04-02 18:55:47 +00:00
parent 28b003faec
commit 788c94a197

View File

@ -34,6 +34,7 @@
<li><a href="#загрузка">Загрузка</a></li>
<li><a href="#примеры">Примеры</a></li>
<li><a href="csv">CSV</a></li>
<li><a href="лицензия">Лицензия</a></li>
</ol>
</details>
@ -278,7 +279,7 @@ futriix:~> dbx select * from testbook
10) "F"
```
#### CSV
### CSV
```sql
futriix:~> dbx select * into csv "/tmp/testbook.csv" from phonebook where pos > 2
1) Kevin Louis,111-2123-1233,2009-12-31,6,F
@ -290,46 +291,9 @@ Kenneth Cheng,123-12134-123,2000-12-31,5,M
$
```
### Delete statement
You may also use Insert and Delete statement to operate the hash. If you does not provide the where clause, it will delete all the records of the specified key prefix. (i.e. phonebook)
```sql
futriix:~> dbx delete from phonebook where gender = F
(integer) 2
futriix:~> dbx delete from phonebook
(integer) 2
```
#### Оператор "From" для импорта CSV-файла
Модуль обеспечивает простую функцию импорта, указав предложение from в операторе Insert. Он поддерживает только разделители-запятые. Убедитесь, что указанный файл импорта доступен серверу Futriix.
### Insert statement
The module provides simple Insert statement which same as the function of the ValkeyS command hmset. It will append a random string to your provided key (i.e. phonebook). If operation is successful, it will return the key name.
```sql
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Peter Nelson' ,1-456-1246-3421, 2019-10-01, 3, M)
"phonebook:1588298418-551514504"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Betty Joan' ,1-444-9999-1112, 2019-12-01, 1, F)
"phonebook:1588299191-764848276"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Bloody Mary' ,1-666-1234-9812, 2018-01-31, 2, F)
"phonebook:1588299196-2115347437"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Mattias Swensson' ,1-888-3333-1412, 2017-06-30, 4, M)
"phonebook:1588299202-1052597574"
futriix:~> hgetall phonebook:1588298418-551514504
1) "name"
2) "Peter Nelson"
3) "tel"
4) "1-456-1246-3421"
5) "birth"
6) "2019-10-01"
7) "pos"
8) "3"
9) "gender"
10) "M"
futriix:~>
```
Note that Valkeys requires at least one space after the single and double quoted arguments, otherwise you will get ``Invalid argument(s)`` error. If you don't want to take care of this, you could quote the whole SQL statement by double quote as below:
```sql
futriix:~> dbx "insert into phonebook (name,tel,birth,pos,gender) values ('Peter Nelson','1-456-1246-3421','2019-10-01',3, 'M')"
```
#### From clause for importing CSV file
The module provides simple import function by specifying from clause in Insert statement. It only support comma deliminated. Please make sure that the specified import file can be accessed by Valkeys server.
```bash
$ cat > /tmp/test.csv << EOF
"Kenneth Cheng","123-12134-123","2000-12-31","5","M"
@ -363,9 +327,49 @@ futriix:~> dbx select name from phonebook
2) "Kevin Louis"
```
### Issue command from BASH shell
#### Оператор "Delete"
Вы также можете использовать операторы Insert и Delete для работы с хешем. Если вы не предоставите предложение where, он удалит все записи указанного префикса ключа. (т.е. телефонная книга)
```sql
$ Valkeys-cli dbx select "*" from phonebook where gender = M order by pos desc
futriix:~> dbx delete from phonebook where gender = F
(integer) 2
futriix:~> dbx delete from phonebook
(integer) 2
```
#### Оператор "Insert"
Модуль предоставляет простой оператор Insert, который аналогичен функции команды Futriix hmset. Он добавит случайную строку к предоставленному вами ключу (например, телефонной книге). Если операция прошла успешно, он вернет имя ключа.
```sql
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Peter Nelson' ,1-456-1246-3421, 2019-10-01, 3, M)
"phonebook:1588298418-551514504"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Betty Joan' ,1-444-9999-1112, 2019-12-01, 1, F)
"phonebook:1588299191-764848276"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Bloody Mary' ,1-666-1234-9812, 2018-01-31, 2, F)
"phonebook:1588299196-2115347437"
futriix:~> dbx insert into phonebook (name,tel,birth,pos,gender) values ('Mattias Swensson' ,1-888-3333-1412, 2017-06-30, 4, M)
"phonebook:1588299202-1052597574"
futriix:~> hgetall phonebook:1588298418-551514504
1) "name"
2) "Peter Nelson"
3) "tel"
4) "1-456-1246-3421"
5) "birth"
6) "2019-10-01"
7) "pos"
8) "3"
9) "gender"
10) "M"
futriix:~>
```
Обратите внимание, что Valkeys требует по крайней мере один пробел после аргументов в одинарных и двойных кавычках, в противном случае вы получите ошибку ``Недопустимый аргумент(ы)``. Если вы не хотите этим заниматься, вы можете заключить весь оператор SQL в двойные кавычки, как показано ниже:
```sql
futriix:~> dbx "insert into phonebook (name,tel,birth,pos,gender) values ('Peter Nelson','1-456-1246-3421','2019-10-01',3, 'M')"
```
### Проблема вызова команды из оболочки Bash
```sql
$ futriix-cli dbx select "*" from phonebook where gender = M order by pos desc
1) 1) "name"
2) "Mattias Swensson"
3) "tel"
@ -386,16 +390,17 @@ $ Valkeys-cli dbx select "*" from phonebook where gender = M order by pos desc
8) "3"
9) "gender"
10) "M"
$ Valkeys-cli dbx select name from phonebook where tel like 9812
$ futriix-cli dbx select name from phonebook where tel like 9812
1) 1) name
2) "Bloody Mary"
```
Note that "*" requires double quoted otherwise it will pass all the filename in current directory. Of course you could quote the whole SQL statement.
Обратите внимание, что "*" требует двойных кавычек, иначе будут переданы все имена файлов в текущем каталоге. Конечно, вы можете заключить в кавычки весь оператор SQL.
```sql
$ Futriix-cli dbx "select * from phonebook where gender = M order by pos desc"
$ futriix-cli dbx "select * from phonebook where gender = M order by pos desc"
```
## License
MIT
### Лицензия
Модуль "fdx" распространяется под лицензией MIT.