Results 1 to 2 of 2

Thread: ปัญหาการติดต่อกับ MySQL เกิด error ลง MySQL-Pythonแล้ว

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Location
    มุมตึก
    Posts
    8


    ผมต้องการติดต่อกับ MySQL แต่เกิด error ครับช่วยทีครับ
    ผมใช้ python 2.4 เพราะ 2.5 ไม่มี MySQL-Python Support ถ้ามีช่วยลงลิงค์ให้ด้วยก็ได้นะครับ
    ผมเขียนโค้ดว่า

    >>>import MySQLdb
    >>>conn = MySQLdb.connect('localhost','root','1234','final&#39
    ก็เกิด error ดังนี้

    Traceback (most recent call last):
    File "<pyshell#2>", line 1, in -toplevel-
    conn = MySQLdb.connect(&#39;localhost&#39;,&#39;root&#39;,&#39;1234&#39;,&#39;final&#39
    File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 75, in Connect
    return Connection(*args, **kwargs)
    File "C:\Python24\Lib\site-packages\MySQLdb\connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
    OperationalError: (1045, "Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)")

    ช่วยทีนะครับ

    อีกคำถาม Python 2.4 ไม่มี lib ของ Tkinter มาให้หรอครับ

  2. #2
    Junior Member
    Join Date
    Apr 2006
    Location
    Thailand
    Posts
    15


    import MySQLdb

    # Create a connection object and create a cursor
    Con = MySQLdb.Connect(host="127.0.0.1", user="root", passwd="1234" db="final")
    Cursor = Con.cursor()

    # Make SQL string and execute it
    sql = "SELECT * FROM Users"
    Cursor.execute(sql)

    # Fetch all results from the cursor into a sequence and close the connection
    Results = Cursor.fetchall()
    Con.close()

    2.4 มี Tkinterครับ และ 2.5 รองรับ MySQLdb ครับ

Similar Threads

  1. mySQL query error เมื่อคลิ๊กที่ Username
    By teaworm in forum แจ้งปัญหาการใช้งานบอร์ด
    Replies: 0
    Last Post: 11-03-2010, 12:36 AM
  2. Replies: 0
    Last Post: 28-11-2007, 11:17 PM
  3. MySQL 5.0.17 ERROR 1054 Unknown column
    By asylu3 in forum PHP,ASP,Javascript, Html
    Replies: 0
    Last Post: 11-02-2006, 03:39 PM
  4. Replies: 2
    Last Post: 31-01-2003, 12:16 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •