3
3
import logging
4
4
import sqlalchemy
5
5
import hashlib
6
- from rdflib import BNode
7
- from rdflib import Literal
8
- from rdflib import RDF
9
- from rdflib import URIRef
6
+ from rdflib import (
7
+ BNode ,
8
+ Literal ,
9
+ RDF ,
10
+ URIRef
11
+ )
10
12
from rdflib .graph import Graph
11
13
from rdflib .graph import QuotedGraph
12
14
from rdflib .store import Store # , NodePickler
@@ -224,7 +226,7 @@ def createTerm(
224
226
rt = Literal (termString , objLanguage )
225
227
store .literalCache [((termString , objLanguage ))] = rt
226
228
elif objDatatype and not objLanguage :
227
- rt = Literal (termString , objDatatype )
229
+ rt = Literal (termString , datatype = objDatatype )
228
230
store .literalCache [((termString , objDatatype ))] = rt
229
231
elif not objLanguage and not objDatatype :
230
232
rt = Literal (termString )
@@ -319,7 +321,7 @@ def py2executeSQL(self, cursor, qStr, params=None, paramList=False):
319
321
(here) is to fill the parameters in-place surrounding each param
320
322
with quote characters
321
323
"""
322
- # print("SQLGenerator ", qStr,params)
324
+ # print("py2executeSQL ", qStr, params)
323
325
if not params :
324
326
querystr = qStr .replace ('"' , "'" )
325
327
cursor .execute (unicode (querystr ))
@@ -345,22 +347,23 @@ def pycompat_executeSQL(self, cursor, qStr, params=None, paramList=False):
345
347
with quote characters
346
348
"""
347
349
# if isinstance(qStr, bytes): qStr = qStr.decode()
350
+ # print("pycompat_executeSQL", qStr, params)
348
351
try :
349
352
if qStr is None :
350
353
raise ValueError ("Query must be a string, it cannot be None" )
351
354
qStr = qStr .decode ()
352
355
except :
353
356
pass
354
357
355
- def py_to_sql (param ):
358
+ def py3_to_sql (param ):
356
359
if param is None :
357
360
return 'NULL'
358
361
if isinstance (param , int ):
359
362
return param
360
363
try :
361
364
return "'%s'" % param .decode ()
362
365
except :
363
- return param
366
+ return "'%s'" % param
364
367
365
368
# _logger.debug("SQLGenerator %s - %s" % (qStr,params))
366
369
if not params :
@@ -374,7 +377,7 @@ def py_to_sql(param):
374
377
elif paramList :
375
378
raise Exception ("Not supported!" )
376
379
else :
377
- params = tuple (map (py_to_sql , params ))
380
+ params = tuple (map (py3_to_sql , params ))
378
381
querystr = qStr .replace ('"' , "'" )
379
382
querystr = querystr % params
380
383
# if isinstance(qStr, bytes): qStr = qStr.decode()
@@ -1331,10 +1334,10 @@ def __repr__(self):
1331
1334
"contexts, %s classification assertions, " +
1332
1335
"%s quoted statements, %s property/value " +
1333
1336
"assertions, and %s other assertions>" % (
1334
- len ([c for c in self .contexts ()]),
1337
+ len ([ctx for ctx in self .contexts ()]),
1335
1338
typeLen , quotedLen , literalLen , assertedLen ))
1336
1339
except Exception :
1337
- return "<Partitioned MySQL N3 Store>"
1340
+ return "<Partitioned SQL N3 Store>"
1338
1341
1339
1342
def __len__ (self , context = None ):
1340
1343
""" Number of statements in the store. """
@@ -1599,8 +1602,8 @@ def bind(self, prefix, namespace):
1599
1602
trans = self .connection .begin ()
1600
1603
try :
1601
1604
c .execute (
1602
- "INSERT INTO %s_namespace_binds " +
1603
- "(prefix,uri) VALUES ('%s', '%s')" % (
1605
+ ( "INSERT INTO %s_namespace_binds " +
1606
+ "(prefix,uri) VALUES ('%s', '%s')" ) % (
1604
1607
self ._internedId ,
1605
1608
prefix ,
1606
1609
namespace ))
0 commit comments