[SR-Users] Loading multiple htables from db on startup? (Kamailio 1.5)

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 8 10:46:27 CEST 2011


Hello,

On 7/5/11 8:21 PM, Alex Balashov wrote:
> On 07/05/2011 01:51 PM, Alex Balashov wrote:
>> On 07/05/2011 11:46 AM, Robin Rodriguez wrote:
>>
>>> So it uses the first defined database table, but then the last
>>> defined key_name and key_value.
>>
>> This appears to just be an oversight in the design of the module
>> parameters. One can define multiple tables, but the rest of the
>> modparams are global.
>>
>> As a workaround, I would suggest a view. Alias the columns identically
>> in the view, but map them to different underlying columns in the
>> different table.
>
> ... well, if you intend to write to them, only some databases support 
> that.  MySQL does.  Not sure about Postgres or others.
writing back to db from a hash table is possible with devel version (it 
can be done at shutdown time).

Using view is a good option working with all versions. Another one, 
starting with 3.0, is to use event_route[htable:mod-init] { ... }

You can use sqlops to do a query to whatsoever table and the load the 
records in htable. Be sure you load sqlops module first to be 
initialized at the time htable modules is initialized. Or, just call a 
Lua script where db connection is intialized and data loaded from there 
-- this one will work nicely starting with 3.2 since htable exports 
native API to lua.

Just some ideas ...

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list