0

I'm using ubuntu 10.10, and after making the mistake of installing LAMP, (was unable to connect to a database with it), I came here and read how important it is to use apt-get install python-mysqldb instead. Deleted LAMP, re-installed using apt-get, and am now getting the same error when trying to run a basic server_version.py script.

The script is the server_version.py found here: http://www.kitebird.com/articles/pydbapi.html

My server_version.py script:

# server_version.py - retrieve and display database server version

import MySQLdb

# I have also tried setting host = 'localhost'
conn = MySQLdb.connect (host = "/opt/lampp/var/mysql/mysql.sock",
                user = "root",
                passwd = "myrealpass",
                db = "testdb1")


cursor = conn.cursor ()
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]
cursor.close ()
conn.close ()

The error is:

Traceback (most recent call last): File "server_version.py", line 10, in db = "testdb1")

File "/usr/lib/pymodules/python2.6/MySQLdb/init.py", line 81, in Connect return Connection(*args, **kwargs)

File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 129, in init from converters import conversions

File "/usr/lib/pymodules/python2.6/MySQLdb/converters.py", line 165, in from decimal import Decimal

File "/usr/lib/python2.6/decimal.py", line 137, in import copy as _copy

File "/home/browning/copy.py", line 4, in

ValueError: need more than 1 value to unpack

Just trying to get some basic experience using databases with python here, so I'm not set on MySQL if there is a better option. I have attempted to re-install mysqldb multiple times using apt-get and pip.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
rabunc
  • 67
  • 5

1 Answers1

3

It looks like you have a file named copy.py that is being picked up instead of the Python standard library module copy. Rename or delete your file (and copy.pyc if it was created). Or run from a different directory.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • Thanks Ned, that did the trick! I'd upvote you but I haven't quite met the point threshold yet. – rabunc Nov 02 '11 at 06:50