| | |
MySQL and Python
Thread Solved
![]() |
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
I am trying to create an authentication script. I am trying to use the PASSWORD function within Mysql but it wont work. Any ideas
if i put PASSWORD('password') it just get the encryption for password and not the variable
Python Syntax (Toggle Plain Text)
#!/usr/bin/python # e begoli, python connector for mysql # import MySQL module import MySQLdb import cgi print "Content-type: text/html\n" # connection db = MySQLdb.connect(host = "localhost", user = "dsfdsfds1", passwd = "dsfdsfdsfsdM5HQ", db = "dsfdsfdsfdsfdsf") form = cgi.FieldStorage() if form.has_key("username")and form["username"].value !="" and form.has_key("password") and form["password"].value !="": username = form["username"].value password = form["password"].value # create a database cursor cursor = db.cursor() # execute SQL select statement cursor.execute("SELECT * FROM User WHERE UserName = username AND Password = PASSWORD(password)") # get the number of rows in the resultset numrows = int(cursor.rowcount) if numrows ==1: print "your in" else: print "you are not authorised to view this page"
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
solved it by doing
Python Syntax (Toggle Plain Text)
cursor.execute("SELECT * FROM User WHERE UserName = username AND Password = PASSWORD('"+password+"')")
![]() |
Similar Threads
- Code to connect mysql through python (Python)
- MySQL + Python (Python)
- Connection of python and mysql (Python)
- Moving to Python From PHP: Using a variable in a function (Python)
- design customized mysql frontend with perl or python (MySQL)
Other Threads in the Python Forum
- Previous Thread: WindowsError: [Error 206] The filename or extension is too long:
- Next Thread: Which gui toolkit and why??
| Thread Tools | Search this Thread |
abrupt accessdenied advanced ansi anti apache application approximation argv array backend beginner binary builtin calculator change command converter countpasswordentry csv curved dan08 def dictionary edit event file float format function google heads homework inches input jaunty java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric obexftp output parameters parsing path phonebook pointer prime programming py2exe pygame pyopengl python random recursion redirect remote return reverse scrolledtext session software sprite statictext statistics string strings syntax terminal text thread threading time tlapse tuple twoup ubuntu unicode unit urllib urllib2 variable voip wordgame write wxpython





