Switched from stringstream to fmt::Writer

For building the sql queries.