Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code_examples/mysql/connection.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database
3 changes: 3 additions & 0 deletions code_examples/mysql/create_table.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database

mysqlCreateTable("users", "id INT NOT NULL, name VARCHAR(20), PRIMARY KEY (ID)");//table, fields
2 changes: 2 additions & 0 deletions code_examples/mysql/delete_value.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database
mysqlDeleteFromTable("users", "id = 0");//output: Record deleted successfully
2 changes: 2 additions & 0 deletions code_examples/mysql/drop_table.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database
mysqlDropTable("users");//Table 'users' deleted successfully
4 changes: 4 additions & 0 deletions code_examples/mysql/get_tables.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database

mysqlShowTables();//output: ["users"]
mysqlShowTableColumns("users"); //output: ["id", "name"]
2 changes: 2 additions & 0 deletions code_examples/mysql/insertValue.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database
mysqlInsertIntoTable("users", ({"id": 0,"name": "Lucas"}));
4 changes: 4 additions & 0 deletions code_examples/mysql/select_values.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database

mysqlGetFromTable("users", "*", "name = 'Lucas'");//output: [{id:0, name:Lucas}]
mysqlGetFromTable("users", "name", "name = 'Lucas' and id = 0");//output: [{name:Lucas}]
2 changes: 2 additions & 0 deletions code_examples/mysql/update_value.zum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysqlConnection("0.0.0.0","3306","root","123456789","zumbra");//host, port, user, password, database
mysqlUpdateIntoTable("users", {"name": "José Lucas"}, "id = 0");//output: Record updated successfully
5 changes: 5 additions & 0 deletions evaluator/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func init() {
"sendEmail", "sendWhatsapp",
}

mysql := []string{
"mysqlConnection", "mysqlCreateTable", "mysqlDeleteFromTable", "mysqlDropTable", "mysqlGetFromTable", "mysqlInsertIntoTable", "mysqlShowTables", "mysqlShowTableColumns", "mysqlUpdateIntoTable",
}

numbersUtils := []string{
"bhaskara", "randomFloat", "randomInteger",
}
Expand All @@ -52,6 +56,7 @@ func init() {
allBuiltins = append(allBuiltins, ioUtils...)
allBuiltins = append(allBuiltins, messages...)
allBuiltins = append(allBuiltins, extras...)
allBuiltins = append(allBuiltins, mysql...)

for _, name := range allBuiltins {
if builtin := builtins.GetBuiltinByName(name); builtin != nil {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module zumbra
go 1.24.2

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/go-sql-driver/mysql v1.9.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
)

require (
github.com/twilio/twilio-go v1.25.1
)
require github.com/twilio/twilio-go v1.25.1
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
Expand Down
27 changes: 27 additions & 0 deletions object/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,33 @@ var Builtins = []struct {
{
"min", MinBuiltin(),
},
{
"mysqlConnection", MySqlConnectionBuiltin(),
},
{
"mysqlCreateTable", mysqlCreateTableBuiltin(),
},
{
"mysqlDeleteFromTable", mysqlDeleteFromTableBuiltin(),
},
{
"mysqlDropTable", mysqlDeleteTableBuiltin(),
},
{
"mysqlGetFromTable", mysqlGetFromTableBuiltin(),
},
{
"mysqlInsertIntoTable", mysqlInsertIntoTableBuiltin(),
},
{
"mysqlShowTables", mysqlShowTablesBuiltin(),
},
{
"mysqlShowTableColumns", mysqlShowTableColumnsBuiltin(),
},
{
"mysqlUpdateIntoTable", mysqlUpdateIntoTableBuiltin(),
},
{
"organize", OrganizeBuiltins(),
},
Expand Down
Loading