Now I downloaded Rich and I'm trying to put my inventory.db into a table.
I have this:
My question is, how do I work around this error, so I can display my Quantity, Price, and Sell_Price?
Thanks.
This is my CreateTable.py so you can see how my inventory.db is formatted :
I have this:
from rich.console import Console from rich.table import Table import sqlite3 #Connect to the inventory database (inventory.db) connection = sqlite3.connect("inventory.db") cursor = connection.cursor() cursor = connection.cursor() #Display all records in the Items Table: cursor.execute('select * from items') #Get all info from the Items Table result = cursor.fetchall() table = Table(title="Item Display") table.add_column("Name", justify="right", style="cyan", no_wrap=True) table.add_column("Quantity", style="magenta") table.add_column("Price($)", justify="right", style="green") table.add_column("Sell Price($)", justify="right", style="blue") for row in result: table.add_row(row[1],row[2],row[3],row[4]) connection.close() console = Console() console.print(table)But when I run it I get this error:
Error: line 460, in add_row
raise errors.NotRenderableError(
rich.errors.NotRenderableError: unable to render int; a string or other renderable object is required
The reason I get this error is because I take in Quantity and Price as an INT. I need those values to be INTs because I do caluclations with them later on. My question is, how do I work around this error, so I can display my Quantity, Price, and Sell_Price?
Thanks.
This is my CreateTable.py so you can see how my inventory.db is formatted :
import sqlite3 def createDatabase(): #Create a database (inventory.db) connection = sqlite3.connect("inventory.db") cursor = connection.cursor() table = """CREATE TABLE IF NOT EXISTS Items (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, Quantity INT NOT NULL, Price DOUBLE NOT NULL, Sell_Price DOUBLE, Description TEXT, Category TEXT, Location TEXT NOT NULL, Length_Ft INT, Barcode INT, Image BLOB, Date Updated datetime default current_timestamp);""" #Execute the creation of the table cursor.execute(table) #print("The database has been created") #Commit the changes connection.commit() #Close the connection connection.close()