def main_generate(table_names, stream):
    """This will print out valid prom python code for given tables that already exist
    in a database.

    This is really handy when you want to bootstrap an existing database to work
    with prom and don't want to manually create Orm objects for the tables you want
    to use, let `generate` do it for you
    """
    with stream.open() as fp:
        fp.write_line("from datetime import datetime, date")
        fp.write_line("from decimal import Decimal")
        fp.write_line("from prom import Orm, Field")
        fp.write_newlines()

        for table_name, inter, fields in get_table_info(*table_names):
            fp.write_line("class {}(Orm):".format(table_name.title().replace("_", "")))
            fp.write_line("    table_name = '{}'".format(table_name))
            if inter.connection_config.name:
                fp.write_line("    connection_name = '{}'".format(inter.connection_config.name))

            fp.write_newlines()
            magic_field_names = set(["_id", "_created", "_updated"])

            if "_id" in fields:
                fp.write_line(get_field_def("_id", fields.pop("_id")))
                magic_field_names.discard("_id")

            for field_name, field_d in fields.items():
                fp.write_line(get_field_def(field_name, field_d))

            for magic_field_name in magic_field_names:
                if magic_field_name not in fields:
                    fp.write_line("    {} = None".format(magic_field_name))

            fp.write_newlines(2)
This will print out valid prom python code for given tables that already exist
    in a database.

    This is really handy when you want to bootstrap an existing database to work
    with prom and don't want to manually create Orm objects for the tables you want
    to use, let `generate` do it for you