Home > OS >  Create line graph from database that assigns lines to each name
Create line graph from database that assigns lines to each name

Time:11-24

I have an SQLite table I want to make a line graph from:

import sqlite3

conn = sqlite3.connect('sales_sheet.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS sales(id INTEGER PRIMARY KEY NOT NULL, 
            sales_rep TEXT,
            client TEXT,
            number_of_sales INTEGER)""")

case1 = ("Jon","Apple", 5)
case2 = ("Judy","Amazon", 6)
case3 = ("Jon","Walmart", 4)
case4 = ("Don","Twitter", 8)
case5 = ("Don","Walmart", 4)
case6 = ("Judy","Google", 7)
case7 = ("Judy","Tesla", 3)
case8 = ("Jon","Microsoft", 7)
case9 = ("Don", "SpaceX", 5)

insert = """INSERT INTO sales(sales_rep, client, number_of_sales) VALUES(?,?,?)"""

cur.execute(insert, case1)
cur.execute(insert, case2)
cur.execute(insert, case3)
cur.execute(insert, case4)
cur.execute(insert, case5)
cur.execute(insert, case6)
cur.execute(insert, case7)
cur.execute(insert, case8)
cur.execute(insert, case9)

conn.commit()
conn.close()

Table:

enter image description here

I want x-axis of numbers in id column and y-axis as number of sales with a line with color coding to represent each sales rep. How to do this?

CodePudding user response:

You can use enter image description here

  • Related