Here is my function.
from tkinter import *
import psycopg2
def search(title=None, isbn=None, year=0):
'''Search the database rows'''
conn = psycopg2.connect("dbname='books'")
cur = conn.cursor()
cur.execute("SELECT books.title, books.isbn, books.year FROM books WHERE books.title = title OR books.isbn = books.isbn OR books.year = year")
rows = cur.fetchone()
conn.close()
return rows