def set_db_schema_version(conn, new_version):
    'Function to set the DB version number in the database.'
    with conn.cursor() as cur:
        cur.execute('SELECT COUNT(*) FROM schema_version')
        num_rows = cur.fetchone()[0]
        assert (num_rows <= 1)
        if (num_rows > 0):
            cur.execute('UPDATE schema_version SET version = %s', [new_version])
        else:
            cur.execute('INSERT INTO schema_version(version) VALUES(%s)', [new_version])
Function to set the DB version number in the database.
def set_db_schema_version(conn, new_version):
    
    with conn.cursor() as cur:
        cur.execute('SELECT COUNT(*) FROM schema_version')
        num_rows = cur.fetchone()[0]
        assert (num_rows <= 1)
        if (num_rows > 0):
            cur.execute('UPDATE schema_version SET version = %s', [new_version])
        else:
            cur.execute('INSERT INTO schema_version(version) VALUES(%s)', [new_version])