mirror of
				https://github.com/mewtek/i2ME-Legacy.git
				synced 2025-06-10 05:30:00 -05:00 
			
		
		
		
	Add grabber functions to the LFRecord in py2Lib
This commit is contained in:
		@@ -1,10 +1,44 @@
 | 
			
		||||
import sqlite3
 | 
			
		||||
 | 
			
		||||
# Make a connection to the LFRecord database
 | 
			
		||||
con = sqlite3.connect("records/LFRecord.db")
 | 
			
		||||
cur = con.cursor()
 | 
			
		||||
 | 
			
		||||
""" General Handler for quickly grabbing resources pertaining to LFRecords. """
 | 
			
		||||
 | 
			
		||||
def getZip(locId: str):
 | 
			
		||||
    pass
 | 
			
		||||
    """ Returns the zip code for a given location """
 | 
			
		||||
    COMMAND = (f"SELECT zip2locId FROM lfrecord WHERE locId='{locId}'")
 | 
			
		||||
    cur.execute(COMMAND)
 | 
			
		||||
    return cur.fetchone()[0]
 | 
			
		||||
 | 
			
		||||
def getCoopId(locId: str):
 | 
			
		||||
    """ Returns the TWC co-op ID for a given location """
 | 
			
		||||
    COMMAND = (f"SELECT coopId FROM lfrecord WHERE locId='{locId}'")
 | 
			
		||||
    cur.execute(COMMAND)
 | 
			
		||||
    return cur.fetchone()[0]
 | 
			
		||||
 | 
			
		||||
def getEpaId(locId: str):
 | 
			
		||||
    """ Return the Air Quality station id for a given location. """
 | 
			
		||||
    COMMAND = (f"SELECT epaId FROM lfrecord WHERE locId='{locId}'")
 | 
			
		||||
    cur.execute(COMMAND)
 | 
			
		||||
    return cur.fetchone()[0]
 | 
			
		||||
 | 
			
		||||
def getPollenInfo(locId: str):
 | 
			
		||||
    """ Return the Pollen forecast id for a given location. """
 | 
			
		||||
    COMMAND = (f"SELECT pllnId FROM lfrecord WHERE locId='{locId}'")
 | 
			
		||||
    cur.execute(COMMAND)
 | 
			
		||||
    return cur.fetchone()[0]
 | 
			
		||||
 | 
			
		||||
def getLatLong(locId: str):
 | 
			
		||||
    """ Return the Pollen forecast id for a given location. """
 | 
			
		||||
    COMMAND = (f"SELECT lat,long FROM lfrecord WHERE locId='{locId}'")
 | 
			
		||||
    cur.execute(COMMAND)
 | 
			
		||||
    fetched = cur.fetchone()
 | 
			
		||||
    return fetched[0] + "/" + fetched[1]
 | 
			
		||||
 | 
			
		||||
def getLocationInfo(locId: str):
 | 
			
		||||
    pass
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
print(getCoopId('USAZ0278'))
 | 
			
		||||
print(getZip('USAZ0278'))
 | 
			
		||||
print(getLatLong('USAZ0278'))
 | 
			
		||||
		Reference in New Issue
	
	Block a user