| 123456789101112131415161718192021222324252627282930 |
- #!/usr/bin/python3
- import mysql.connector
- from tabulate import tabulate
- host='192.168.100.26'
- user='landsearchuser'
- password='1234'
- database='landsearch'
- def closedb():
- """Cleanly close the db."""
- cursor.close()
- cnx.close()
- cnx = mysql.connector.connect(host=host, user=user, password=password, database=database, buffered=True)
- cursor = cnx.cursor()
- cursor.execute('SELECT id, MLS, address, sqft, acres, zoning, price, time_to_school/60, time_to_work/60, link, notes FROM properties WHERE time_to_school < 1800 ORDER BY time_to_school ASC')
- results = cursor.fetchall()
- print(tabulate(results, headers=['ID', 'MLS', 'Address', 'sqft', 'acres', 'zoning', 'price', 'school (min)', 'work(min)', 'link', 'notes']))
- #print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
- #for result in results:
- # print(tabulate([[result[0], result[1]]]))
- closedb
|