whenever I run this code it leaves a list that is like ['1999','2000',] and therefore I cannot perform an operation like ' m, b = np.polyfit(x, y, 1)'
def getCH4():
years = []
ch4 = []
try:
sqlConnect = sqlite3.connect('table1.db')
cursor = sqlConnect.cursor()
print("connected for reading")
sqlite_SelectQuery = """SELECT * from datahub"""
cursor.execute(sqlite_SelectQuery)
records = cursor.fetchall()
for row in records:
years.append(row[0])
ch4.append(row[2])
cursor.close()
except sqlite3.Error as error:
print("Failed to read data from sqlite table", error)
finally:
if (sqlConnect):
sqlConnect.close()
print("The SQLite connection is closed")
time.sleep(1)
return years, ch4