<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Jon,</div><div>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:</div><div><br></div><div><a href="http://kamailio.org/docs/modules/4.4.x/modules/sqlops.html#idm20488">http://kamailio.org/docs/modules/4.4.x/modules/sqlops.html#idm20488</a></div><div><br></div><div><pre class="programlisting" style="border: 1px solid rgb(153, 204, 204); padding-left: 15pt; widows: 1; background-color: rgb(254, 254, 238); position: static; z-index: auto;">modparam("sqlops","sqlcon","cb=><a href="mysql://kamailio:abc@10.10.1.1/testdb">mysql://kamailio:abc@10.10.1.1/testdb</a>")
modparam("sqlops","sqlcon","ca=><a href="dbdriver://username:password@dbhost/dbname">dbdriver://username:password@dbhost/dbname</a>")
...</pre></div><div><pre class="programlisting" style="border: 1px solid rgb(153, 204, 204); padding-left: 15pt; widows: 1; background-color: rgb(254, 254, 238); position: static; z-index: auto;">...
sql_query("ca", "select * from domain", "ra");
xlog("number of rows in table domain: $dbr(ra=>rows)\n");
sql_result_free("ra");</pre><div>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.</div></div><div><br></div><div>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.</div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br></div></div><div><div>On 5 Apr 2016, at 12:57, Jon Bonilla (Manwe) <<a href="mailto:manwe@aholab.ehu.es">manwe@aholab.ehu.es</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi all<br><br>I have multiple auth credentials split among multiple databases (same server).<br>I want to extract the password from the correct database for each request and<br>pass it as arameter to the auth functions.<br><br>The problem is, how can I use sqlops and select the correct database in<br>realtime? the db connection already contains the database to connect to. <br><br>Would it if I use a default connection but I put the db I want i the query?<br>Something like:<br><br>select * from database.table ...<br>select * from $avp(s:database).table where i=1...<br><br><br><br>cheers,<br><br>Jon<br><br>_______________________________________________<br>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br></blockquote></div><br></body></html>