I'm trying to write a set of Python classes that would query a database to retrieve some values then construct a network graph. Problem is I get this error whenever I try to call the constructor for one of my classes The relevant code is as follows
class NetworkConstructor:
def __init__(self):
self.nodes=dict()
self.queryservice=QueryService()
self.graph=networkx.Graph()
And the relevant bits from QueryService class is
def __init__(self):
self.connect()
def connect(self):
self.conn=MySQLdb.Connect(host="xxx", port=3306,user="xxx",passwd="xxx",db="xxx")
self.cursor=self.conn.cursor()
And I have imported all required libraries as well
Looks like your QueryService class is in a module with the same name. Try
self.queryservice=QueryService.QueryService()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.