Python Forum
How to check if the data is empty in a database?
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if the data is empty in a database?
#1
Hi,
I'm fetching the data from the database and I would like to check the data above of the data in the same rows as the per channel to see if the cell is empty.

Here is for example table:

---------------------------
| channel   | program_id
---------------------------
| ITV       |
| ITV       | 3021
| ITV       | 3022
| ITV       | 3023


Here is the code:

def update_in_database(self):
     profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', 'source.db'))
     conn = database.connect(profilePath)
     cur = conn.cursor()
     program_id = ''.join(str(x) for x in self.program_id)
     cur.execute('SELECT channel, program_id FROM programs WHERE program_id=?;', (program_id,))
     data = cur.fetchone()


     if data:
       #check if the data above the 3021 in a database is empty
Here is the output for the data:

(u'103 ITV', u'3021')
I have got a string of program_id which it is 3021, so I want to check the string in a database to see if the data above of the 3021 is empty so I could do something.

How I can check in a database to see if the data above of the string is empty or not?
Reply


Messages In This Thread
How to check if the data is empty in a database? - by chris0147 - Aug-19-2017, 03:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 448 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  how do you style data frame that has empty rows. gsaray101 0 544 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  How to detect abnormal data in big database python vanphuht91 5 1,170 Jun-27-2023, 11:22 PM
Last Post: Skaperen
  Database that can compress a column, or all data, automatically? Calab 3 1,233 May-22-2023, 03:25 AM
Last Post: Calab
  [SOLVED] [sqilte3] Check if column not empty? Winfried 5 1,154 Jan-28-2023, 12:53 PM
Last Post: Winfried
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,416 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Showing an empty chart, then input data via function kgall89 0 994 Jun-02-2022, 01:53 AM
Last Post: kgall89
  I need help parsing through data and creating a database using beautiful soup username369 1 1,728 Sep-22-2021, 08:45 PM
Last Post: Larz60+
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,205 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Looping to read data in database CEC68 1 1,739 Sep-24-2020, 08:54 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020