1Rex::Commands::DB(3)  User Contributed Perl Documentation Rex::Commands::DB(3)
2
3
4

NAME

6       Rex::Commands::DB - Simple Database Access
7

DESCRIPTION

9       This module gives you simple access to a database. Currently select,
10       delete, insert and update is supported.
11
12       Version <= 1.0: All these functions will not be reported.
13

SYNOPSIS

15        use Rex::Commands::DB {
16                         dsn    => "DBI:mysql:database=test;host=dbhost",
17                         user    => "username",
18                         password => "password",
19                       };
20
21        task "list", sub {
22          my @data = db select => {
23                   fields => "*",
24                   from  => "table",
25                   where  => "enabled=1",
26                 };
27
28         db insert => "table", {
29                  field1 => "value1",
30                   field2 => "value2",
31                   field3 => 5,
32                 };
33
34         db update => "table", {
35                     set => {
36                       field1 => "newvalue",
37                       field2 => "newvalue2",
38                     },
39                     where => "id=5",
40                  };
41
42         db delete => "table", {
43                   where => "id < 5",
44                 };
45
46        };
47

EXPORTED FUNCTIONS

49   db
50       Do a database action.
51
52        my @data = db select => {
53                 fields => "*",
54                 from  => "table",
55                 where  => "host='myhost'",
56               };
57
58        db insert => "table", {
59                 field1 => "value1",
60                 field2 => "value2",
61                 field3 => 5,
62               };
63
64        db update => "table", {
65                   set => {
66                     field1 => "newvalue",
67                     field2 => "newvalue2",
68                   },
69                   where => "id=5",
70                };
71
72        db delete => "table", {
73                 where => "id < 5",
74               };
75
76
77
78perl v5.36.1                      2023-08-07              Rex::Commands::DB(3)
Impressum