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

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Dec 31 10:12:24 CET 2008


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





More information about the Users mailing list