MySQL
MySQL is an open-source relational database engine. In Gredit, this integration allows connecting to a MySQL or MariaDB instance to execute SQL queries from scripts via ODBC.
What it is used for
Configure a MySQL connection so that scripts can execute SQL queries and read or write data in a relational database.
Configuration
Required data
| Field | Description |
|---|---|
Host | MySQL server address (IP or hostname) |
Database | Database name |
Port | Connection port (default: 3306) |
Username / UID | Connection user |
Password / PWD | User password |

Adding the database in Gredit
- Go to the Databases section and create a new configuration.
- Fill in the host, database, port, username, and password.
- In Driver, enter the exact name of the ODBC driver installed on the server (for example,
MySQLorMariaDB Unicode). If in doubt, validate with Support. - The Name value will be the identifier used to inject the connection into scripts.
Usage in scripts
Ruby
require 'odbc_utf8'
con = ODBC.connect('TestMYSQL')
stmt = con.run('SELECT id, nombre FROM usuarios')
columns = stmt.columns.keys.map(&:downcase)
stmt.each do |row|
h = columns.zip(row).to_h
puts h['nombre']
end
stmt.drop
con.disconnect
Python
Add the
pyodbclibrary under Libraries in the script settings.

import pyodbc
cnxn_sql = gredit.connect('TestMYSQL')
cursor = cnxn_sql.cursor()
cursor.execute("SELECT id, nombre FROM usuarios")
columns = [col[0].lower() for col in cursor.description]
for row in cursor.fetchall():
h = dict(zip(columns, row))
print(h["nombre"])
cursor.close()
cnxn_sql.close()
Relationship with other modules
- Accounts: The MySQL connection belongs to an account.
- Scripts: Can be associated with one or more scripts optionally.
- Permissions: Controlled by assigned roles and permissions.