[Dovecot] Updating Database records from a Plugin

Timo Sirainen tss at iki.fi
Tue Aug 3 15:27:28 EEST 2010


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.



More information about the dovecot mailing list