我有一个mysql服务器正在运行,可以从Django ORM连接到它。无法使用rdflib功能连接。如何调试此问题?谢谢。
rdflib 2.4.2,python2.6,MySQL社区5.1.42
追踪:
configString = "host=localhost,user=root,password=...,db=..."
print configStringhost=localhost,user=root,password=.,db=.
store = plugin.get('MySQL', Store)('rdfstore')
print store 回溯(最近一次调用):
文件"D:\GR\Personal\Career\Python\medCE\semantix\foaf_rdf.py",第26行,在打印存储中
文件“C:\ Files\Python26\lib\site-packages\rdflib\store\MySQL.py",第1029行,在_____repr_____ c=self._db.cursor()
AttributeError:“NoneType”对象没有属性“游标”
rt = store.open(configString,create=False) 表kb_7b066eca61_relations不存在
表kb_7b066eca61_relations不存在
print rt 0
if rt == 0: store.open(configString,create=True) 回溯(最近一次调用):
文件"",第3行,在
store.open(configString,create=True)文件“C:\ Files\Python26\lib\site-packages\rdflib\store\MySQL.py",第602行,打开
host=configDict['host'],文件“C:\ Files\Python26\lib\site-packages\MySQLdb__init__.py",第74行,连接”
return Connection(\*args, \*\*kwargs)文件“C:\ Files\Python26\lib\site-packages\MySQLdb\connections.py",第170行,在init中
super(Connection, self).**init**(\*args, \*\*kwargs2)OperationalError:(1049年,“未知数据库‘测试”)
发布于 2010-02-04 21:51:45
我在MySQL.py中的rdflib/store目录中注释了代码,现在所有代码都能工作了:
# test_db = MySQLdb.connect(user=configDict['user'],
# passwd=configDict['password'],
# db='test',
# port=configDict['port'],
# host=configDict['host'],
# #use_unicode=True,
# #read_default_file='/etc/my-client.cnf'
# )
# c=test_db.cursor()
# c.execute("""SET AUTOCOMMIT=0""")
# c.execute("""SHOW DATABASES""")
# if not (configDict['db'].encode('utf-8'),) in c.fetchall():
# print >> sys.stderr, "creating %s (doesn't exist)"%(configDict['db'])
# c.execute("""CREATE DATABASE %s"""%(configDict['db'],))
# test_db.commit()
# c.close()
# test_db.close()https://stackoverflow.com/questions/2197157
复制相似问题