Example #1
0
def map_subs_ids(subs_names, subs_titles):
    db = PostgresConn()
    subs_ids = {
        name: db.get_id_or_create("nome", [name], ["id"], "reddit", "subreddits", ["nome", "titulo"], [name, title])
        for name, title in zip(subs_names, subs_titles)
    }
    db.close()
    return subs_ids
Example #2
0
def query_page_id_or_create(page):
    db = PostgresConn()
    res = db.get_id_or_create(filter_field="nome",
                              filter_values=[page],
                              fields=["id", "nome"],
                              schema="noticias",
                              table="paginas",
                              insert_fields=["nome"],
                              insert_values=[page])
    return res