I'm working with dvdrental database and I want to limit the rental table by choosing a specific rental_date.
When i print content of rental_date I receive a table like:
[(datetime.datetime(2005, 5, 24, 22, 54, 33),), (datetime.datetime(2005, 5, 24, 23, 3, 39),), ...
I tried to limit my rental table by using code like this:
import psycopg2 as pg
conn = pg.connect(host='localhost', port='5432', dbname='dvdrental', user='postgres', password='123')
cur = conn.cursor()
cur.execute("SELECT * FROM rental WHERE rental_date=datetime.datetime(2005, 5, 24, 22, 54, 33),")
The result of that code is syntax error. After removing comma I got error:
InvalidSchemaName: schema "datetime" does not exist
Is there any possibility to get access to that datetime.datetime data type in my cur.execute command?
Thank you for your answers :)
I'm using Python 3.9.4 and psycopg2 2.9.3