开发者

Trouble with rdfstore with mysql - how to debug?

I have a mysql server running and can connect to it from my Django ORM. Can't connect using the rdflib functionality. How can I debug this problem? Thanks.

rdflib 2.4.2, python 2.6, MySQL Community 5.1.42

Trace:

configString = "host=localhost,user=root,password=...,db=..."  
print configString

host=localhost,user=root,password=...,db=...

store = plugin.get('MySQL', Store)('rdfstore')  
print store  

Traceback (most recent call last):

File "D:\GR\Personal\Career\Python\medCE\semantix\foaf_rdf.py", line 26, in print store

File "C:\Program Files\Python26\lib\site-packages\rdflib\store\MySQL.py", line 1029, in _____repr_____ c=self._db.cursor()

AttributeError: 'NoneType' object has no attribute 'cursor'

rt = store.open(configString,create=False)  

table kb_7b066eca61_relations Doesn't exist

table kb_7b066eca61_relations Doesn't exist

print rt  

0

if rt == 0: store.open(configString,create=True)  

Traceback (most recent call last):

File "", line 3, in

store.open(configString,create=True)

File "C:\Program Files\Python26\lib\site-packages\rdflib\store\MySQL.py", line 602, in open

host=configDict['host'],

File "C:\Program Files\Python26\lib\sit开发者_运维问答e-packages\MySQLdb__init__.py", line 74, in Connect

return Connection(*args, **kwargs)

File "C:\Program Files\Python26\lib\site-packages\MySQLdb\connections.py", line 170, in init

super(Connection, self).init(*args, **kwargs2)

OperationalError: (1049, "Unknown database 'test'")


I commented code in the rdflib/store directory in MySQL.py and now it all works:

# 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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜