[% USE format -%]
[% indented = format('%-15s %s') -%]
#include <pslib.h>
#include <[% pkg_name %].h>
#include <stdlib.h>

int main ()
{
[% FOREACH table = tables -%]
    {
        psDB            *dbh;
        [% indented(table.object_name, "*object") %];

        dbh = psDBInit("localhost", "test", NULL, "test");
        if (!dbh) {
            exit(EXIT_FAILURE);
        }

        object = [% table.object_name %]Alloc(
[%- SET i = 0 -%]
[%- FOREACH item = table.columns -%]
    [%- IF i == 0 -%][%- i = 1 -%][%- ELSE -%], [% END -%] [%- item.test -%]
[%- END -%]
);
        if (!object) {
            exit(EXIT_FAILURE);
        }

        if (![% table.namespace %]InsertObject(dbh, object)) {
            exit(EXIT_FAILURE);
        }

        psFree(object);
        psDBCleanup(dbh);
    }

[% END -%]
    exit(EXIT_SUCCESS);
}
