In [8]:
# import sqlite3 here
In [21]:
#open connection to database
In [10]:
# 1st challenge: Write a sql query to search for the name: zoidberg
# Note: It will return 0
It returned empty because there is no zoidberg in our list.
Add it below.
Name: Zoidberg
Legal name: Planet Express
City: New New York
State: New New York
In [1]:
# Add the zoidberg data to the database below. remeber to commit()
In [12]:
# Search for zoidberg again. This time, you should get the results below:
Next: Compare the number of practices in New york (NY) vs Texas (Tx)
In [13]:
# Count number of practices in New York vs Texas
# 1st, get number in New York. You should get the values below
print("Number in NY: ", len(result))
In [5]:
# Now get Texas:
print("Number in TX: ", len(result))
Next: Find the number of people with John in their name
In [25]:
# Find number of Johns. Remember, this uses the % symbol
There is a problem with the above: It will include names like Johnathan.
What if we only want people with the name John?
Hint: In the search query, use 'john %'. Notice the space before %
Try that below:
In [23]:
print(len(result))
#This time, printing the 1st 6 results as well, to check.
print(result[:6])
In [27]:
# Now find all Johns in the state 'AL'
print(len(result))
print(result[:6])
In [28]:
# Finally, Johns in AL and city of Mobile.
print(len(result))
print(result[:6])
In [29]:
#Always close the database!
conn.close()
In [ ]: