1

I have a GridDB container for the sqllite database I am implementing into my Student Management app, but I need to GET RID of the NULL values on the database. How can I delete the rows and not make them appear on the app? I have tried to Here is an image of a sample of how the app looks like.Five rows showing two NULL values

import pandas as pd
import griddb_python as griddb
from kivy.metrics import dp
from kivy.uix.anchorlayout import AnchorLayout
from kivymd.app import MDApp
from kivymd.uix.datatables import MDDataTable
from kivymd.uix.label import MDLabel
import sqllite3

factory = griddb.StoreFactory.get_instance()

try:
    gridstore = factory.get_store(host="127.0.0.1", port="8080", 
            cluster_name="Cluster12", username="root", 
            password="")
    conInfo = griddb.ContainerInfo("Students_DB",
                    [              
                     ["Student ID", griddb.Type.INTEGER],
                     ["First Name", griddb.Type.STRING],
                     ["Last Name", griddb.Type.STRING],
                     ["Gender", griddb.Type.STRING,
                     ["DOB", griddb.Type.STRING],
                     ["Current Year", griddb.Type.INTEGER],
                     ["CGPA", griddb.Type.FLOAT],
                    ],
                    griddb.ContainerType.COLLECTION, True)
    con = gridstore.put_container(conInfo)   
    # Reading Database into a Pandas DataFrame
    container = sqlite3.connect("StudentsDB.db")
    df = pd.read_sql_query("SELECT * from best_students", container)


    # Adding the database
    for i in range(len(df)):
        ret = con.put(df.iloc[i, :])

except Exception as e:
    print(e)

sql_statement = ('SELECT * FROM Students_DB')
sql_query = pd.read_sql_query(sql_statement, con)

class Students(MDApp):
    def build(self):
        layout = AnchorLayout()
        title = MDLabel(
                            text = "Students Record Management(SRM)",
                            theme_text_color = "Custom",
                            text_color = (0, 0, 0, 1),
                            pos_hint = {"center_x": .5, "center_y": .8},
                            size_hint_x = 1,
                            halign = "center"
            )
#...
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

I am not sure at what place you would like to remove the NULL values. But griddb syntax accepts removing null using this syntax in the query:

SELECT * from best_students where <columnName> IS NOT NULL

Remember changing columnName to what ever column you prefer removing NULL from.

[EDIT] I saw you image later on. If you like to remove NULL from Last Name you should write like this:

SELECT * from best_students where 'Last Name' IS NOT NULL

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94