On 05/04/16 14:18, Paul Smith wrote:
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.

Indeed the database url would expect a database name, iirc. However, if it is the same username and password for both databases, it might work. I haven't tried, but in mysql, if I did 'use database x', I can still do queries to another database by prefixing the table names with the database name, like 'select * from y.test'.

The easiest way to figure out is to make a test with sql_query() doing "select * from y.table ..." through a connection to database x.

Cheers,
Daniel



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



_______________________________________________
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

-- 
Daniel-Constantin Mierla
http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com