<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>use:</p>
<p>modparam("htable", "htable",
"isp=>size=8;dbtable=isp;cols=ispname,ispip,ispuser,ipsprefix,ispprefix")<br>
</p>
<p>then you have the $sht(ispname) with value corresponding to
"ispip,ispuser,ipsprefix,ispprefix" and then you can use
{s.select,,0} to get ispname value, then {s.select,,1} to get
ispip value, etc...</p>
<p>An alternative would be to keep only two columns in database, one
(the key) with ispname and the second (the value) all fields
serialized in a json document and you use jansson to parse them in
config.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<div class="moz-cite-prefix">On 07.08.20 13:06, Ilie Soltanici
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAJQ6-U2d9Gx9_xE-TiUJ2akFSSxVr50X=xUdfyPmuWj=sCgzCg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hello,</div>
<div><br>
</div>
<div>What will be the best way to save ISP Information in
Kamailio memory?</div>
<div><br>
</div>
<div>I have the following information for each ISP into the DB:</div>
<div><br>
</div>
<div><b>ISP Name | ISP IP | ISP Username | ISP Password | ISP
Prefix</b></div>
<div>ISP1 | 1.1.1.1 | user |
pass | 1234<b><br>
</b></div>
<div><br>
</div>
<div>This info it's not changed/updated too often, so I want to
avoid querying the DB on every call and get this info directly
from the memory.</div>
<div><br>
</div>
<div>I was thinking to use htable for that, so I created a
htable as an array for that and loaded all the information
there manually, something like that:</div>
<div><br>
</div>
<div><b>kamcmd htable.sets isp ISP1[address] 1.1.1.1</b></div>
<div><b>
kamcmd htable.sets isp ISP1[username] user</b></div>
<div><b>
kamcmd htable.sets isp ISP1[password] pass</b></div>
<div><b>
kamcmd htable.sets isp ISP1[prefix] 1234 <br>
</b></div>
<div><b><br>
</b></div>
<div><b>$sht(
isp =>
ISP1[address]) == "1.1.1.1"</b></div>
<div><b>
$sht(
isp =>
ISP1[username]) == "user" <br>
</b></div>
<div><b>
$sht(
isp =>
ISP1[password]) == "pass" <br>
</b></div>
<div><b>
$sht(
isp =>
ISP1[prefix]) == "1234"
</b>
</div>
<div><br>
</div>
<div>So far so good, I'm able to get this information from the
htable and use it whenever I need it.</div>
<div>Now, the problem comes when I want to load all this
information automatically from the DB. How can I setup htable
module to get the array key (address, username...) from the
database automatically on server restart, and append this
array_key to the column value?</div>
<div><br>
</div>
<div>I've tried this way: <br>
</div>
<div>
<div style="color:rgb(171,178,191);background-color:rgb(40,44,52);font-family:"Fira Code",Consolas,"Courier New",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(198,120,221)">modparam</span><span style="color:rgb(171,178,191)">(</span><span style="color:rgb(152,195,121)">"htable"</span><span style="color:rgb(171,178,191)">, </span><span style="color:rgb(152,195,121)">"htable"</span><span style="color:rgb(171,178,191)">, </span><span style="color:rgb(152,195,121)">"isp=>size=8;dbtable=isp;cols='trunk_name[address],trunk_address'"</span><span style="color:rgb(171,178,191)">)</span></div></div>
</div>
<div><br>
</div>
<div>But it's not working unfortunately, getting back this
error: You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right
syntax to use near '[address]'</div>
<div><br>
</div>
<div>If I'm setting this way:<br>
</div>
<div>
<div style="color:rgb(171,178,191);background-color:rgb(40,44,52);font-family:"Fira Code",Consolas,"Courier New",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(198,120,221)">modparam</span><span style="color:rgb(171,178,191)">(</span><span style="color:rgb(152,195,121)">"htable"</span><span style="color:rgb(171,178,191)">, </span><span style="color:rgb(152,195,121)">"htable"</span><span style="color:rgb(171,178,191)">, </span><span style="color:rgb(152,195,121)">"isp=>size=8;dbtable=isp;cols='trunk_name,trunk_address'"</span><span style="color:rgb(171,178,191)">)</span></div></div>
</div>
<div><br>
</div>
<div>and setting trunk_name value to: ISP1[address], then it's
working fine, but in this case I will have to create by one
column for each array key, which may be confusing and it's a
lot of unnecessarily information into the DB.</div>
<div>Is it possible to do that, or better to trigger a script on
each restart which will load this information from the DB into
htable?</div>
<div>Thanks<br>
</div>
<div><br>
</div>
<div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
</body>
</html>