[Dovecot] Updating Database records from a Plugin
Guys,
In the file /etc/dovecot-pgsql.conf I have driver = pgsql connect = host=localhost dbname=ivr.db user=ivr password=passwd default_pass_scheme = PLAIN password_query = SELECT password FROM embedded_device WHERE username='%u' user_query = SELECT home, uid, gid FROM embedded_device WHERE username='%u'
In the table embedded_device there is a field called PIN.
My plugin has the "user" and the "pin_value". What I want to do from the plugin is the following:
UPDATE embedded_device SET PIN=pin_value WHERE username=user;
Questions: Is there a way to locate the exiting database open connection? Is there a way to use the dovecot sql API to set the value of field?
I have been looking for examples and have not been very successful.
Regards,
John
On Tue, 2010-08-03 at 17:10 +1000, John O'Brien wrote:
What I want to do from the plugin is the following:
UPDATE embedded_device SET PIN=pin_value WHERE username=user;
Questions: Is there a way to locate the exiting database open connection? Is there a way to use the dovecot sql API to set the value of field?
How about doing it via dict API? You can use e.g. dict_set("private/pin", "value") to update the pin. Then configure a dict sql mapping, something like:
map { pattern = priv/pin table = quota username_field = username value_field = pin }
See quota-dict and expire plugins how to use dict.
participants (2)
-
John O'Brien
-
Timo Sirainen