Advertisement
Guest User

Untitled

a guest
Mar 7th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. import mysql.connector
  2.  
  3. db = mysql.connector.connect(user="root", password="",
  4.                             host="127.0.0.1",
  5.                             database="test")
  6.  
  7. cursor = db.cursor()
  8.  
  9.  
  10. try:
  11.     cursor.execute('SELECT tail_number FROM aircraft')
  12.     tail_number = cursor.fetchall()
  13.     cursor.execute('SELECT model_number FROM model')
  14.     model_number = cursor.fetchall()
  15.     cursor.execute('SELECT description FROM model')
  16.     description = cursor.fetchall()
  17.     cursor.execute('SELECT company_name FROM companies')
  18.     company_name = cursor.fetchall()
  19.     cursor.execute('SELECT model_number FROM model')
  20.     model_number = cursor.fetchall()
  21.     cursor.execute('SELECT code FROM country_codes')
  22.     code = cursor.fetchall()
  23.     cursor.execute('SELECT country_name FROM country_codes')
  24.     country_name = cursor.fetchall()
  25.  
  26.     html = """
  27.    <table>
  28.    <caption>European Aircraft</caption>
  29.    <tr>
  30.    <th>Tail Number</th>
  31.    <th>Model Number</th>
  32.    <th>Model Description</th>
  33.    <th>Company Name</th>
  34.    <th>Company Country Code</th>
  35.    <th>Company Country</th>
  36.    </tr>
  37.    </table>
  38.  
  39.    <table>
  40.    <caption>Non-European Aircraft</caption>
  41.    <th>Tail Number</th>
  42.    <th>Model Number</th>
  43.    <th>Model Description</th>
  44.    <th>Company Name</th>
  45.    <th>Company Country Code</th>
  46.    <th>Company Country</th>
  47.    </tr>
  48.    <tr></tr>
  49.    </table>
  50.    """
  51.  
  52.  
  53.  
  54.     print html
  55.  
  56.  
  57. finally:
  58.     db.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement