| | |
Need wxpython, sqlite3, python help.
![]() |
•
•
Join Date: Oct 2009
Posts: 10
Reputation:
Solved Threads: 0
OK I have a search script that suppose to search for information in my database. The problem I having is that I want the user to be able to enter a last name to search.
The only part that is giving me problems is this part, I'm stuck on this part.
Traceback (most recent call last):
File "C:/Users/Panic/Desktop/Contacts/search.py", line 46, in OnStart
db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = (results)")
sqlite3.OperationalError: no such column: results
Here is the rest of the code that I am not having problems with.
Thanks to anyone who can lend help with this.
The only part that is giving me problems is this part, I'm stuck on this part.
Python Syntax (Toggle Plain Text)
db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = (results)")
Traceback (most recent call last):
File "C:/Users/Panic/Desktop/Contacts/search.py", line 46, in OnStart
db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = (results)")
sqlite3.OperationalError: no such column: results
Here is the rest of the code that I am not having problems with.
Python Syntax (Toggle Plain Text)
#Importing modules import os import wx import sqlite3 import Database #Creating a class class search(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, 'Search', size = (400,100)) panel = wx.Panel(self, -1) #Centering the frame self.Centre() #Creating input fields searchLabel = wx.StaticText(panel, -1, " Search:") self.search = wx.TextCtrl(panel, -1, "Enter last name") searchLabel.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL)) self.search.SetInsertionPoint(0) #Creating sizers sizer = wx.FlexGridSizer(cols = 8, hgap = 8, vgap = 8) sizer.AddMany([searchLabel, self.search]) panel.SetSizer(sizer) #Creating buttons and events start = wx.Button(panel, label = 'Start', pos = (225, 0), size = (80, 25)) start.Bind(wx.EVT_BUTTON, self.OnStart, start) results = self.search.GetValue() def OnStart(self, event): dlg = wx.MessageBox("Start search?", 'Message', wx.YES_NO | wx.ICON_QUESTION) if (dlg == wx.YES): file = open (r'Database.py', 'r') exec(file.read()) db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = (results)") else: self.Destroy() if __name__ == '__main__': myApp = wx.App() frame = search() frame.Show() myApp.MainLoop()
Thanks to anyone who can lend help with this.
0
#2 Oct 26th, 2009
You've simply forgotten to put the value of
HTH
results into the string. Instead you mistakenly typed the name results. Here's how you should use string formatting to add the value: python Syntax (Toggle Plain Text)
db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = (%s)" % results)
•
•
Join Date: Jul 2009
Posts: 4
Reputation:
Solved Threads: 1
0
#3 Oct 26th, 2009
I believe there may be two problems. Results appears to be undefined within the function. Either pass in results as an argument or use self.results. (The original definition of results should also be made in the method above.
Secondly, the syntax of the pysqlite statement appears to be incorrect try..
Secondly, the syntax of the pysqlite statement appears to be incorrect try..
Python Syntax (Toggle Plain Text)
db.execute("SElECT fname, lname, phone, address, email from contacts WHERE lname = %s" % self.results)
![]() |
Similar Threads
- Starting wxPython (GUI code) (Python)
- wxPython Events help (Python)
- Sync-up Python, wxPython, XRCed, BoaConstructor (Python)
- How to create menu in python? (Python)
- Python tutorials? (Python)
- Python Executable (Py2Exe) (Python)
- wxpython (Python)
- Dropdown box in Python (Python)
- Instal of wxPython (Python)
Other Threads in the Python Forum
- Previous Thread: Run DOS batch file (requires users input) in Python
- Next Thread: How to search a string from a list item?
| Thread Tools | Search this Thread |
advanced ajax aliased apax array backend bash beginner book c++ calculator code console convert corners curves customdialog dan08 data database dictionary digital dynamic dynamically edit embed examples exe file function getvalue gui hints input itunes java leftmouse line linux list lists loop maze module mouse movingimageswithpygame multiple myregfun mysqldb mysqlquery newb obexftp opensource output path phonebook programming projects py py2exe pygame pyglet pyopengl pyqt python random redirect remote return rubyconf script shebang silverlight skinning slicenotation software sqlite statictext string syntax table thread threading time tooltip tricks tutorial ubuntu urllib urllib2 variable ventrilo verify whileloop wikipedia windows wordgame wx.wizard wxpython xlwt







