Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbUmd-0006mQ-Sv for psycopg@arkaria.postgresql.org; Mon, 04 Apr 2022 22:02:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbUmc-000502-15 for psycopg@arkaria.postgresql.org; Mon, 04 Apr 2022 22:02:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbUmb-0004zt-QY for psycopg@lists.postgresql.org; Mon, 04 Apr 2022 22:02:45 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbUmZ-0002L9-AQ for psycopg@postgresql.org; Mon, 04 Apr 2022 22:02:45 +0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id C7F032A0107 for ; Mon, 4 Apr 2022 15:02:40 -0700 (PDT) Date: Mon, 4 Apr 2022 15:02:40 -0700 (PDT) From: Rich Shepard Reply-To: Rich Shepard To: psycopg@postgresql.org Subject: cur.execute() syntax error Message-ID: <9471b149-dd21-5040-3693-c6f54ddc3b36@appl-ecosys.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This MWE (test_combobox.py) produces a syntax error and I'm not seeing why: ----- import tkinter as tk from tkinter import ttk import psycopg2 class ContactDataForm(tk.Frame): # set up postgres # the connection con = psycopg2.connect(database='bustrac') # the cursor cur = con.cursor() def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) # A dict to keep track of input widgets self.inputs = {} self.inputs['Contact Type'] = LabelInput( ContactDataForm, 'contact_type', # query to fetch data from contacttypes table fetch_all = "SELECT * from contacttypes" cur.execute(fetch_all) # fetching all rows rows = cur.fetchall() input_class=ttk.Combobox([values = rows]) input_var=tk.StringVar() # get selected value and bind it to a method cont_type = self.get() # selected value by mouse click con.close() ) self.inputs['Contact Type'].grid(row0, column1) ContactDataForm.grid(row=0, column=0, sticky='we') ----- When run from the shell: $ python test_combobox.py File "test_combobox.py", line 24 cur.execute(fetch_all) ^ SyntaxError: invalid syntax Here python is python3 by default. What am I not seeing? Rich