Example #1
0
def DeleteEvent(id):
    con = getConn()
    cursor = con.cursor()
    sql = "delete from events where idno = {id}".format(id=id)
    print(sql)
    cursor.execute(sql)
    con.commit()
Example #2
0
def SaveEvent(id, header):
    sql = """update optionspakshidev.events set header='{header}'
           where idno={id} """
    sql = sql.format(sql, header=header, id=id)
    print("sql", sql)
    conn = getConn()
    cursor = conn.cursor()
    cursor.execute(sql)
    conn.commit()
Example #3
0
def getEventData(id):
    conn = getConn()
    cursor = conn.cursor()
    cursor.execute("select *  from events where idno = {id}".format(id=id))
    row = cursor.fetchall()[0]
    a = {
        "idno": row[0],
        "newsdate": row[1],
        "header": row[2],
        "type": row[3],
        "impact": int(row[4]),
        "impactrationale": row[5],
        "url": row[6],
        "effectivedate": row[7]
    }
    return a
Example #4
0
def getdata(id):
    conn = getConn()
    cursor = conn.cursor()
    if id == 0 or id is None:
        row = list(str(' ') * 8)
    else:
        cursor.execute("select *  from events where idno = {id}".format(id=id))
        row = cursor.fetchall()[0]
    a = {
        "idno": row[0],
        "newsdate": row[1],
        "header": row[2],
        "type": row[3],
        "impact": row[4],
        "impactrationale": row[5],
        "url": row[6],
        "effectivedate": row[7]
    }
    return render_template('events.html', data=a)
Example #5
0
def postEventsList():

    con = getConn()
    cursor = con.cursor()
    cursor.execute("select *  from events")
    rows = cursor.fetchall()
    values = list()
    for row in rows:
        values.update({
            "id": row[0],
            "newsdate": row[1],
            "header": row[2],
            "type": row[3],
            "impact": row[4],
            "impactrationale": row[5],
            "url": row[6],
            "effectivedate": row[7]
        })
    return values
Example #6
0
def getEventsList():
    #a={}
    #return render_template('table.html', data=a)
    con = getConn()
    cursor = con.cursor()
    cursor.execute("select *  from events")
    rows = cursor.fetchall()
    values = list()
    for row in rows:
        values.append({
            "id": row[0],
            "newsdate": row[1],
            "header": row[2],
            "type": row[3],
            "impact": row[4],
            "impactrationale": row[5],
            "url": row[6],
            "effectivedate": row[7]
        })
    return values
Example #7
0
def postdata():
    idno = request.form.get('idno')
    newsdate = request.form.get('newsdate')
    header = request.form.get('header')
    newstype = request.form.get('type')
    impact = request.form.get('impact')
    impactrationale = request.form.get('impactrationale')
    url = request.form.get('url')
    effectivedate = request.form.get('effectivedate')

    if idno == 0 or idno is None or idno == ' ':
        sql = """insert INTO events (newsdate, header, newstype, impact, impactrationale, url, effectivedate) 
       VALUES ('{newsdate}', '{header}', '{newstype}', '{impact}', '{impactrationale}', '{url}', '{effectivedate}')"""
        sql = sql.format(sql,
                         idno=idno,
                         newsdate=newsdate,
                         header=header,
                         newstype=newstype,
                         impact=impact,
                         impactrationale=impactrationale,
                         url=url,
                         effectivedate=effectivedate)
    else:
        sql = """update events set newsdate='{newsdate}', header='{header}', newstype='{newstype}', impact={impact}, impactrationale='{impactrationale}', url='{url}', effectivedate='{effectivedate}' 
          where idno={idno} """
        sql = sql.format(sql,
                         newsdate=newsdate,
                         header=header,
                         newstype=newstype,
                         impact=impact,
                         impactrationale=impactrationale,
                         url=url,
                         effectivedate=effectivedate,
                         idno=idno)

    print("sql", sql)
    conn = getConn()
    cursor = conn.cursor()
    cursor.execute(sql)
    conn.commit()
    return getdata(idno)