Ok so im trying to import a class i made which connects to a MySQL database the class code is shown below:
class connection
def__init__( self ):
self.cnx = MySQLdb.connect(user='xxx',host='xxx',passwd='xxx',db='xxx')
All of the parameters for the mysql connection are correct and file containg the class is in the same directory as the PSP file. The class file is called cnx_class.py
when i run my PSP file i get 'cnx' isnt defined. My psp code is below:
<psp:file>
import cnx_class
</psp:file>
<%
cur = cnx.cursor()
cur.execute('select * from protein;')
rows = cur.fetchall()
for row in rows:
req.write`(row)`
#end
%>
any help?