Python SQL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Creating Connection

A

conn = Main_Menu.create_connection(“Candles Database”)
cur = conn.cursor()

def create_connection(connstr):
conn = None
try:
conn = sqlite3.connect(connstr)
except Exception as e:
print(e)
return conn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SELECT (with LIKE)

A

sql = (“SELECT OldCustomerOrders.CustomerOrderID FROM OldCustomerOrders WHERE OldCustomerOrders.CustomerOrderID LIKE ‘%” + word + “%’”)
cur.execute(sql)
self.x = cur.fetchall()

OR

cur.execute(“SELECT Forename, Surname, Orders, OldCustomerOrders.CustomerOrderID FROM Customers, OldCustomerOrders WHERE Customers.CustomerID = OldCustomerOrders.CustomerID”)
_fetched = cur.fetchall()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly