Leon,<br><br>Two things: first, would you mind putting this info into the wiki? Just create this page:<br><a href="http://wiki.freeswitch.org/index.php?title=Mod_odbc&action=edit&redlink=1">http://wiki.freeswitch.org/index.php?title=Mod_odbc&action=edit&redlink=1</a><br>
<br>Second, I was curious what kind of throughput you've seen with this? Just curious how much you think it might scale. I'm sure someone will find a way to mix this with SIPp in an effort to break it. :P<br><br>-MC<br>
<br><div class="gmail_quote">On Mon, Sep 14, 2009 at 7:23 PM, Leon de Rooij <span dir="ltr"><<a href="mailto:leon@scarlet-internet.nl">leon@scarlet-internet.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I wrote a new module mod_odbc_query the last few days and I'm wondering<br>
what other people think of it. It works here, tested it and valgrind<br>
sees no leaks..<br>
<br>
You can check it out here:<br>
<a href="http://fisheye.freeswitch.org/browse/FreeSWITCH/contrib/ledr/c/mod_odbc_query" target="_blank">http://fisheye.freeswitch.org/browse/FreeSWITCH/contrib/ledr/c/mod_odbc_query</a><br>
<br>
It's pretty flexible and useful for me.<br>
<br>
regards,<br>
<br>
Leon<br>
<br>
---<br>
<br>
mod_odbc_query readme<br>
<br>
This module can be used for doing odbc queries from the dialplan.<br>
<br>
Usage:<br>
<br>
<application name="odbc_query" data="SELECT some_column_name AS<br>
target_channel_variable_name FROM some_table_name WHERE 1;"/><br>
<br>
or:<br>
<br>
<application name="odbc_query" data="my-query"/><br>
<br>
The module simply checks whether the data attr contains a space. If it<br>
does, then that field will be seen as an SQL query, otherwise it will be<br>
seen as a query 'name' which then has to be defined in the modules<br>
configuration in the <queries> section like this:<br>
<br>
<queries><br>
<query name="my-query" value="SELECT some_column_name AS<br>
target_channel_variable_name FROM some_table_name WHERE 1;"/><br>
</queries><br>
<br>
The module will do the query and store each returned column name as<br>
channel variable name together with its corresponding value.<br>
<br>
Another feature is, that if only two columns are returned, which have<br>
the column names "name" and "value", then the channel variables will be<br>
set according to them. This way you can have the query return multiple<br>
rows with different channel variables. If the query returns something<br>
else than column-names "name" and "value" and it returns multiple rows,<br>
then the channel variables will be overwritten with each iteration of<br>
the rows - which is probably useless.<br>
<br>
The query may contain ${blah} variables that will be expanded from<br>
channel variables before the query is performed.<br>
<br>
<br>
For example:<br>
<br>
query: "SELECT foo, bar FROM huk WHERE tilde='kek';"<br>
<br>
returns:<br>
<br>
foo bar<br>
----------<br>
a b<br>
c d<br>
<br>
then the channel variables that will be set are:<br>
<br>
foo=c<br>
bar=d<br>
<br>
---<br>
<br>
<br>
query: "SELECT foo AS name, bar AS value FROM huk WHERE tilde='kek';"<br>
<br>
returns:<br>
<br>
name value<br>
------------<br>
a b<br>
c d<br>
<br>
then the channel variables that will be set are:<br>
<br>
a=b<br>
c=d<br>
<br>
---<br>
<br>
<br>
So, the first example should only be used when you know that only zero<br>
or one row will be returned, and second one if you know zero or more<br>
rows will be returned.<br>
<br>
If zero rows are returned (in either foo/bar or name/value case) then<br>
no channel variables will be set, overwritten or deleted.<br>
<br>
---<br>
<br>
<configuration name="odbc_query.conf" description="ODBC Query Module"><br>
<br>
<settings><br>
<param name="odbc-dsn" value="freeswitch:freeswitch:secret"/><br>
</settings><br>
<br>
<queries><br>
<!-- the ${foo} variable will be expanded from channel variables at query time --><br>
<query name="map-did-users" value="<br>
SELECT<br>
dir_users.username AS dest_user,<br>
<a href="http://dir_domains.name" target="_blank">dir_domains.name</a> AS dest_domain<br>
FROM<br>
map_did_users, dir_domains, dir_users<br>
WHERE<br>
map_did_users.did='${destination_number}' AND<br>
<a href="http://dir_users.id" target="_blank">dir_users.id</a> = map_did_users.user_id AND<br>
<a href="http://dir_domains.id" target="_blank">dir_domains.id</a> = dir_users.dir_domain_id;"/><br>
</queries><br>
</configuration><br>
<br>
<br>
_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br>