Building Chatbots in Python
Alan Nichol
Co-founder and CTO, Rasa
name | pricerange | area | rating |
---|---|---|---|
Bill's Burgers | hi | east | 3 |
Moe's Plaice | low | north | 3 |
Sushi Corner | mid | center | 3 |
SELECT * from restaurants;
SELECT name, rating from restaurants;
SELECT name from restaurants
WHERE area = 'center' AND pricerange = 'hi';
import sqlite3
conn = sqlite3.connect('hotels.db')
c = conn.cursor()
c.execute("SELECT * FROM hotels WHERE area='south' and pricerange='hi'")
<sqlite3.Cursor at 0x10cd5a960>
c.fetchall()
[('Grand Hotel', 'hi', 'south', 5)]
# Bad Idea query = "SELECT name from restaurant where area='{}'".format(area) c.execute(query)
# Better t = (area,price) c.execute('SELECT * FROM hotels WHERE area=? and price=?', t)
Building Chatbots in Python