public inbox for [email protected]
help / color / mirror / Atom feedFrom: Rich Shepard <[email protected]>
To: [email protected]
Subject: cur.execute() syntax error
Date: Mon, 4 Apr 2022 15:02:40 -0700 (PDT)
Message-ID: <[email protected]> (raw)
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
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: cur.execute() syntax error
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox