Example: Querying Whether a Table Exists 
In this example, you use the cmd method (Loader class) and the sql method (Loader class) of the sdb.loader module fto log on to a database and query whether a specific table exists.
Create a Python script sample.py with the following contents:
Syntax
# Import Python modules
# -------------------------------------------
import sys
import sdb.loader
# Call Loader
# -------------------------------------------
session = sdb.loader.Loader ()
#Logging On to the Database
# -------------------------------------------
session.cmd ("USE USER MONA RED DB DEMODB")
# Query whether table HOTEL.CUSTOMER exists.
# If the table does not exist, the Loader returns
# an error.
# -------------------------------------
sqlrc = session.sql("EXISTS TABLE HOTEL.CUSTOMER")
if (sqlrc == 0):
print 'Table HOTEL.CUSTOMER exists.'
elif (sqlrc == -4004):
print 'Error -4004: Table HOTEL.CUSTOMER does not exist.'
# Close connection to the database
# -------------------------------------
session.release ()
Call the Python script:
python sample.py