Rewrite database connector using C API