Hi Jon,
The normal way would be to use multiple modparam lines, one for each of your databases.  Then in your route config you can select and use any of those connections:

http://kamailio.org/docs/modules/4.4.x/modules/sqlops.html#idm20488

modparam("sqlops","sqlcon","cb=>mysql://kamailio:abc@10.10.1.1/testdb")
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");
In your case you might set some variable in the route to select the relevant connection name from your pre-defined list, and then pass that variable to the sql_query() function call.

I think you wanted to have one connection to the database server, and then have function calls to query a database on that server … as far as I know that is not possible.


On 5 Apr 2016, at 12:57, Jon Bonilla (Manwe) <manwe@aholab.ehu.es> wrote:

Hi all

I have multiple auth credentials split among multiple databases (same server).
I want to extract the password from the correct database for each request and
pass it as arameter to the auth functions.

The problem is, how can I use sqlops and select the correct database in
realtime? the db connection already contains the database to connect to.

Would it if I use a default connection but I put the db I want i the query?
Something like:

select * from database.table ...
select * from $avp(s:database).table where i=1...



cheers,

Jon

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users