File size: 979 Bytes
9d5168a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# tasks.py
import os
import logging
from redis import Redis
from dotenv import load_dotenv
from celery import Celery
from db.db_utils import get_connection, store_result_to_db

load_dotenv()

# REDIS_URL = os.environ['REDIS_URL']
# app = Celery('tasks', broker=REDIS_URL, backend=REDIS_URL)

# app.conf.update(
#     result_expires=3600,
#     task_serializer='json',
#     result_serializer='json',
#     accept_content=['json'],
#     timezone='UTC',
#     enable_utc=True,
#     broker_connection_retry_on_startup=True
# )
<<<<<<< HEAD

# @app.task
db_conn = get_connection()
db_cursor = db_conn.cursor()

=======

# @app.task
db_conn = get_connection()
db_cursor = db_conn.cursor()
>>>>>>> e938c9da41dfd18544b4ea8aa7107f56cf05b2f2
def insert_result(run_key, mappings):
    for mapping in mappings:
        store_result_to_db(db_cursor, db_conn, run_key, mapping)

<<<<<<< HEAD

# db_conn.close()
=======
    # db_conn.close()
>>>>>>> e938c9da41dfd18544b4ea8aa7107f56cf05b2f2