May-26-2017, 03:44 AM
Hello everyone. I am having a problem formatting a string. That's what it boils down to. I am using a sglite3 database and looking for a date format in the database.
I'll show the code here:
Thanks folks. I've been trying everything I can, but I cannot get the correct quote placement, I think.
I'll show the code here:
def film_list(name, month, year): # YOUR CODE HERE d = "{:4d}{:02d}".format(year,month) query = 'select title, rental_rate, rental_date, return_date, rental_duration\ FROM film JOIN inventory using(film_id)\ JOIN rental using(inventory_id)\ JOIN customer using(customer_id)\ WHERE last_name = "'+ name + '" AND WHERE rental_date LIKE" "{:4d}{:02d}".format(year,month)' print(query) for row in db.execute(query): print(row) return rowMy query prints out like this:
select title, rental_rate, rental_date, return_date, rental_duration FROM film JOIN inventory using(film_id) JOIN rental using(inventory_id) JOIN customer using(customer_id) WHERE last_name = "Ebert" AND WHERE rental_date LIKE" "{:4d}{:02d}".format(year,month)What I'm sending to the function is this:
leo = film_list('Ebert', 6, 2005)I need it to be formatted like this:
assert leo[0] == ('Lonely Elephant', 2.99, '2005-06-16 20:59:35.000', '2005-06-24 15:31:35.000', 3)Everything will should work if I can format the date to look like the above string '2005-06-16 20:59:35.000'.
Thanks folks. I've been trying everything I can, but I cannot get the correct quote placement, I think.