| | |
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 |
address advanced aliased anydbm bash beginner bits calling casino changecolor clear command conversion convert corners count csv cturtle cursor curves definedlines dictionary digital dynamic dynamically events examples excel external file float format frange function gui handling hints homework i/o iframe import input java line linux list lists loan loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame python random rational raw_input recursion recursive return scrolledtext searchingfile shebang signal singleton string strings tails terminal text threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode urllib urllib2 valueerror variable web-scrape whileloop word wxpython





