Пример #1
0
def graphOfChosenStockOverTime():
    # try:
    conn = connect.connector()

    cursor = conn.cursor()
    cursor.execute("SELECT * FROM abbdaily")

    row = cursor.fetchone()

    # take time duration and return highest/lowest growth
    # top 10 stocks on a date

    dates = []
    values = []
    while row is not None:
        dates.append(row[0].strftime('%Y-%m-%d'))
        values.append(row[1])
        row = cursor.fetchone()
    #print (values)
    # print ((dates))
    plt.plot(dates, values)
    plt.xticks(['dfd'], [])
    #plt.show()
    canvas = FigureCanvas(plt)
    response = django.http.HttpResponse(content_type='image/png')
    canvas.print_png(response)
    return response
Пример #2
0
def retTableList():
    conn = connect.connector()
    cursor = conn.cursor()
    cursor.execute("show tables")
    row = cursor.fetchone()
    allTables = []
    while row is not None:
        allTables.append(row[0])
        row = cursor.fetchone()
    return allTables
Пример #3
0
def printTop10(qu, allTables):
    date = input("Enter a date : ")
    date = datetime.strptime(date, "%Y-%m-%d").date(
    )  # <--- error here...how to convert string to datetime object???
    # date = datetime.strptime(date, '%Y-%m-%d')
    print(date)
    # qu += "where recordtime = " + date + ";"
    conn = connect.connector()
    cursor = conn.cursor()
    cursor.execute(qu)
    row = cursor.fetchone()
    print(row)
Пример #4
0
def graph2():
    conn = connect.connector()

    fig = Figure()
    ax = fig.add_subplot(111)

    cursor = conn.cursor()
    cursor.execute("SELECT * FROM abbdaily")
    row = cursor.fetchone()
    dates = []
    values = []
    while row is not None:
        dates.append(row[0].strftime('%Y-%m-%d'))
        values.append(row[1])
        row = cursor.fetchone()
    ax.plot(dates, values)
    #print (values)
    # print ((dates))
    fig.autofmt_xdate()
    canvas = FigureCanvas(fig)

    return canvas