← Volver al índice de módulos

sqlops

The SQLOPS module adds support for raw SQL queries in the configuration file. Among the features: * Multiple database connections - the sqlops module can connect to many databases on different servers
🗄️ Base de Datos Kamailio 6.1 12 parámetros 15 funciones

Descripción general

The SQLOPS module adds support for raw SQL queries in the configuration file. Among the features: * Multiple database connections - the sqlops module can connect to many databases on different servers using different DB driver modules at the same time. * Many query results - the module can store many results of different SQL queries in separate structures at the same time. Thus it is possible to work in parallel with several queries and results. * Access via pseudo-variables - the content of the SQL query result is accessible via pseudo-variables. Please note that only integer and string variables are supported at the moment because of the internal usage of “AVPs” to hold the values. So it is not possible for example to return floating point or big integer values this way. * Array indexes - fast access to result values via array position: [row,column]. * Persistence in process space - a result can be used many times in the same worker process. Query once, use many times. * Results can be stored in xavps - columns are accessed by their names, rows by xavp index. Xavp's are available during the transactions lifetime and don't need to be destroyed manually.

Documentación oficial: https://www.kamailio.org/docs/modules/stable/modules/sqlops.html
Código fuente: https://github.com/kamailio/kamailio/tree/master/src/modules/sqlops

Parámetros de configuración

ParámetroTipoDescripción
sqlcon str 3.2. sqlres (str) 3.3. tr_buf_size (int) 3.4. log_buf_size (int) 3.5. connect_mode (int) 3.6. results_maxsize (int)
sqlres str 3.3. tr_buf_size (int) 3.4. log_buf_size (int) 3.5. connect_mode (int) 3.6. results_maxsize (int)
tr_buf_size int 3.4. log_buf_size (int) 3.5. connect_mode (int) 3.6. results_maxsize (int)
log_buf_size int 3.5. connect_mode (int) 3.6. results_maxsize (int)
connect_mode int 3.6. results_maxsize (int)
results_maxsize int 3.1. sqlcon (str)
sqlcon str The definition of a DB connection. The value of the parameter must have the following format: * "connection_name=>database_url"
sqlres str The definition of a database result ID. The value of the parameter can be any string. Results IDs are also added at fixup time when sql_query() parameters are parsed, so there is no need to declare th
tr_buf_size int The size of the transformations for SQL operations.
log_buf_size int The size of the buffer (characters) when logging raw SQL operations.
connect_mode int Control how the module will connect to database. Values: * 0 connect at start up or fail * 1 connect at start up but continue even if connecting to database server fails * 2 do not connect until neede
results_maxsize int Set the upper limit of how many result containers are going to be defined.

Funciones exportadas

sql_query(connection, query[, result])

4.2. sql_xquery(connection, query, result) 4.3. sql_pvquery(connection, query, result) 4.4. sql_result_free(result) 4.5. sql_query_async(connection, query)

sql_xquery(connection, query, result)

4.3. sql_pvquery(connection, query, result) 4.4. sql_result_free(result) 4.5. sql_query_async(connection, query)

sql_pvquery(connection, query, result)

4.4. sql_result_free(result) 4.5. sql_query_async(connection, query)

sql_result_free(result)

4.5. sql_query_async(connection, query)

sql_query_async(connection, query)

Note that sql_query(), sql_xquery() and sql_pvquery() functions have the following return values: * -1 - error in parameters or query execution * 1 - query successful, at least one row in resultset (for SELECTs) * 2 - query successful, no rows return

sql_query(connection, query[, result])

Make an SQL query using 'connection' and store data in 'result'. * connection - the name of the connection to be used for the query (defined via the “sqlcon” parameter). * query - SQL query string or pseudo-variables containing SQL query. * result -

sql_query()

usage ... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_query("ca", "select * from domain", "ra"); xlog("number of rows in table domain: $dbr(ra=>rows)\n"); sql_result_free("ra"); ...

sql_xquery(connection, query, result)

Make an SQL query using 'connection' and store data in 'result' xavp. * connection - the name of the connection to be used for the query (defined via the “sqlcon” parameter). * query - SQL query string or pseudo-variables containing SQL query. * resu

sql_xquery()

usage ... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_xquery("ca", "select * from domain", "ra"); xlog("first domain: $xavp(ra=>domain) with id: $xavp(ra=>domain_id)\n"); ... if (sql_xquery("ca", "select * fro

sql_pvquery(connection, query, result)

Make an SQL query using 'connection' and store data in arbitrary pseudo variables specified by 'result' parameter. * connection - the name of the connection to be used for query (defined via the “sqlcon” parameter). * query - SQL query string or pseu

sql_pvquery()

usage ... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_pvquery("ca", "select 'col1', 2, NULL, 'sip:test@example.com'", "$var(a), $avp(col2), $xavp(item[0]=>s), $ru"); ...

sql_result_free(result)

Free data in SQL 'result'.

sql_result_free()

usage ... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_query("ca", "select * from domain", "ra"); xlog("number of rows in table domain: $dbr(ra=>rows)\n"); ... sql_result_free("ra"); ...

sql_query_async(connection, query)

Make an async SQL query using 'connection', if implemented by db driver module (e.g., db_mysql). The query is executed in another process and result is not available back to config, thus it should be used only for sql statements that don't return val

sql_query_async()

usage ... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_query_async("ca", "delete from domain"); ...

Autores y contribuidores

Daniel-Constantin Mierla <miconda@gmail.com>

Copyright © 2008 http://www.asipto.com

Módulos relacionados

db2_ops db_cluster db_flatstore db_mongodb db_mysql db_postgres db_redis db_sqlite