How to hide warning about drop table message to MariaDB

^Bart gabriele1NOSPAM at hotmail.com
Sat Jan 18 13:25:20 EST 2020


I ran this code:

#!/usr/bin/python
import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","root","MyPwd","MyDB")

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Drop table if it already exist using execute() method.
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")

# Create table as per requirement
sql = """CREATE TABLE EMPLOYEE (
          FIRST_NAME  CHAR(20) NOT NULL,
          LAST_NAME  CHAR(20),
          AGE INT,
          SEX CHAR(1),
          INCOME FLOAT )"""

cursor.execute(sql)

# disconnect from server
db.close()

The table is created but I have also the below warning and I'd like to 
hide it:

Warning (from warnings module):
   File "/home/gabriele/Corso_4.0/Python/MySQL_create_table.py", line 11
     cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
Warning: (1051, "Unknown table 'gabfood.EMPLOYEE'")
 >>>

How could I do it?
^Bart


More information about the Python-list mailing list