We use Django application, and we use it's DB file for e-mail aliases.
The settings are by conf.d/router/402_exim4-config_virtual_sql.
# members@fsij.org fsij_members: driver = redirect domains = fsij.org condition = ${if eq {$local_part}{members}{yes}{no}} forbid_pipe forbid_file data = ${lookup sqlite {/home/fsij/django/fsij/fsij.db \ select email from auth_user, auth_user_groups, auth_group \ where auth_user_groups.group_id = auth_group.id \ and auth_user.id = auth_user_groups.user_id \ and auth_group.name = 'fsijMember';} \ {$value}fail} errors_to = $local_part-request@fsij.org no_more # board@fsij.org fsij_board: driver = redirect domains = fsij.org condition = ${if eq {$local_part}{board}{yes}{no}} forbid_pipe forbid_file data = ${lookup sqlite {/home/fsij/django/fsij/fsij.db \ select email from auth_user, auth_user_groups, auth_group \ where auth_user_groups.group_id = auth_group.id \ and auth_user.id = auth_user_groups.user_id \ and auth_group.name = 'boardMember';} \ {$value}fail} errors_to = $local_part-request@fsij.org no_more # Lastly, <user>@fsij.org virtual_sql_fsij: driver = redirect domains = fsij.org data = ${lookup sqlite {/home/fsij/django/fsij/fsij.db \ select email from auth_user where username='$local_part';} \ {$value}fail} no_more