[NEW FEATURE] Multi DB connections support in AVPOPS

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[NEW FEATURE] Multi DB connections support in AVPOPS

Bogdan-Andrei Iancu
Hi,

Thanks to a contribution of Kobi Eshun, the avpops module can now
operate with multiple DB connections in the same time. Shortly, you will
be able to operate with multiple databases (even different types of
databases) in the same time.

How it works:
=============

1) define all the DB connections you want to use in AVPOPS module be
multiple definitions of "db_url" param:
        modparam("avpops","db_url","mysql://user:passwd@host/database")
        modparam("avpops","db_url","1 postgres://user:passwd@host/osips")
        modparam("avpops","db_url","2
mysql://user:passwd@localhost/opensips_1_4")
Note that the db url string is prefixed by a numerical id - a db_url
reference number that will be used later to specify what DB connection
to be used.

For backward comaptibility, the id 0 is considered default if missing
and it is considered the default DB connection to be used if no other
one is explicitly given:
        modparam("avpops","db_url","mysql://user:passwd@host/database")
  is the same with:
        modparam("avpops","db_url","0 mysql://user:passwd@host/database")

Also see
http://www.opensips.org/html/docs/modules/devel/avpops.html#id2520921


2) use it - all avp_db_xxxx function takes as optional 3rd parameter the
db connection id. If this param is missing, the default (id 0)
connection is to be assumed.

  Ex:
    # load using default db connection (backward compatible)
    avp_db_load("$fu","$(i:678)");
    # load using db connection id 2
    avp_db_load("$fu","$(i:678)", "2");

Also see
http://www.opensips.org/html/docs/modules/devel/avpops.html#id2511018.

Many thanks to Kobi for his contribution.

Best regards,
Bogdan



_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSIPS-Users] [NEW FEATURE] Multi DB connections support in AVPOPS

Kobi Eshun
Thanks for incorporating this functionality, Bogdan. Great to see you  
extended support for all DB operations, too. I'll convert to using the  
new script functions and let you know if I see any issues. Know that I  
don't routinely exercise the avpdbload() functionality, only the  
avpdbops(). Cheers,

--
kobi


On Dec 31, 2008, at 1:12 AM, Bogdan-Andrei Iancu wrote:

> Thanks to a contribution of Kobi Eshun, the avpops module can now
> operate with multiple DB connections in the same time. Shortly, you  
> will
> be able to operate with multiple databases (even different types of
> databases) in the same time.


_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSIPS-Users] [NEW FEATURE] Multi DB connections support in AVPOPS

Dan Pascu
In reply to this post by Bogdan-Andrei Iancu
On Wednesday 31 December 2008, Bogdan-Andrei Iancu wrote:

> How it works:
> =============
>
> 1) define all the DB connections you want to use in AVPOPS module be
> multiple definitions of "db_url" param:
>         modparam("avpops","db_url","mysql://user:passwd@host/database")
>         modparam("avpops","db_url","1
> postgres://user:passwd@host/osips") modparam("avpops","db_url","2
> mysql://user:passwd@localhost/opensips_1_4")
> Note that the db url string is prefixed by a numerical id - a db_url
> reference number that will be used later to specify what DB connection
> to be used.
>
> 2) use it - all avp_db_xxxx function takes as optional 3rd parameter
> the db connection id. If this param is missing, the default (id 0)
> connection is to be assumed.
>
>   Ex:
>     # load using default db connection (backward compatible)
>     avp_db_load("$fu","$(i:678)");
>     # load using db connection id 2
>     avp_db_load("$fu","$(i:678)", "2");

It would be nicer if names could be used instead of numeric ids to
identify a connection, as they are easier to remember and more user
friendly.

--
Dan

_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSIPS-Users] [NEW FEATURE] Multi DB connections support in AVPOPS

Kobi Eshun
Fair point -- I use M4 to keep track of such constants, so I didn't  
consider it much of a hassle. I'll see how hard it would be to  
implement your request w/out a runtime performance hit. Cheers,
--
kobi


On Jan 6, 2009, at 9:22 AM, Dan Pascu wrote:

>>
>>  Ex:
>>    # load using default db connection (backward compatible)
>>    avp_db_load("$fu","$(i:678)");
>>    # load using db connection id 2
>>    avp_db_load("$fu","$(i:678)", "2");
>
> It would be nicer if names could be used instead of numeric ids to
> identify a connection, as they are easier to remember and more user
> friendly.


_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel