Server-Side Scripting/SQL Databases/Python (Flask)

app.py
"       return result

def country_exists(country): with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor sql = """           SELECT EXISTS(                SELECT * FROM Countries                WHERE Country = ?) AS Count;        """ parameters = (country,) cursor.execute(sql, parameters) result = cursor.fetchone[0] return result

def insert_country(country, temperature): with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor sql = """           INSERT INTO Countries (Country, Temperature)            VALUES(?, ?);        """ parameters = (country, temperature) cursor.execute(sql, parameters) connection.commit

def update_country(country, temperature): with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor sql = """           UPDATE Countries            SET Temperature = ?            WHERE Country = ?;        """ parameters = (temperature, country) cursor.execute(sql, parameters) connection.commit

def delete_country(country): with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor sql = """           DELETE FROM Countries            WHERE Country = ?;        """ parameters = (country, ) cursor.execute(sql, parameters) connection.commit

if __name__ == "__main__": app.run(host='0.0.0.0', port=5000)

Try It
Copy and paste the code above into the following free online development environment or use your own compiler / interpreter / IDE.
 * Repl.it