How to set Cursor in TextField?

"AttributeError: cursor", how to fix it (Python)?

  • I'm trying to set up a python script that connects to a database. After some searching on the world wide web I now have some code which should do just about fine, but I get the following error AttributeError: cursor. I probably have to install a certain package (I'm using Ubuntu). Here's my code: import MySQLdb DB = 'testdb' DB_HOST = 'localhost' DB_USER = 'root' DB_PASSWORD = '' conn = MySQLdb.connection(db=DB, host=DB_HOST, user=DB_USER, passwd=DB_PASSWORD) cursor = conn.cursor () sql = """show tables;""" cursor.execute(sql) results = cursor.fetchall() cursor.close() conn.close() Please help

  • Answer:

    If you are able to import MySQLdb without any problem, then you don't need to install anything else. Try MySQLdb.connect() instead of MySQLdb.connection()

dhldhldh... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.