MySQL Matrix manipulation in Python

Threader Slash threaderslash at gmail.com
Tue Sep 29 10:00:43 CEST 2009


Hello Everybody,

My doubt is about matrix data manipulation in python - I hope someone can
point me some direction.

I googled around, but there is not much good examples about playing with
matrix in python on internet.

My following function works pretty well, and gives me the outup from my
MySQL db:

* Code:
    def employee(self, verifyName):
        runQuery= """.... = %s"""
        self.cursor.execute(runQuery,(verifyName,))
        for row in self.cursor.fetchall():
            print row
        print "Number of lines returned: %d" % self.cursor.rowcount
        print "tell column numbers: %d" % len(row)

* output

('John', 'Plumber')
('Bill', 'Driver')
('Mark', 'Lawyer')
Number of lines returned: 3
tell column numbers: 2

Now, how can I transfer this output to provide a matrix with a content like
this:

my_array = [['John','Plumber'],
['Bill','Driver'],
['Mark','Lawyer']]

All comments and suggestions are highly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090929/5972d02d/attachment.html>


More information about the Python-list mailing list