@@ -927,20 +927,23 @@ def __repr__(self):
927
927
(expression .alias (literal_table , 'literal' ),
928
928
None , ASSERTED_LITERAL_PARTITION ), ]
929
929
q = unionSELECT (selects , distinct = False , selectType = COUNT_SELECT )
930
- with self .engine .connect () as connection :
931
- res = connection .execute (q )
932
- rt = res .fetchall ()
933
- typeLen , quotedLen , assertedLen , literalLen = [
934
- rtTuple [0 ] for rtTuple in rt ]
935
- try :
936
- return ("<Partitioned SQL N3 Store: %s " +
937
- "contexts, %s classification assertions, " +
938
- "%s quoted statements, %s property/value " +
939
- "assertions, and %s other assertions>" % (
940
- len ([ctx for ctx in self .contexts ()]),
941
- typeLen , quotedLen , literalLen , assertedLen ))
942
- except Exception :
943
- return "<Partitioned SQL N3 Store>"
930
+ if hasattr (self , 'engine' ):
931
+ with self .engine .connect () as connection :
932
+ res = connection .execute (q )
933
+ rt = res .fetchall ()
934
+ typeLen , quotedLen , assertedLen , literalLen = [
935
+ rtTuple [0 ] for rtTuple in rt ]
936
+ try :
937
+ return ("<Partitioned SQL N3 Store: %s " +
938
+ "contexts, %s classification assertions, " +
939
+ "%s quoted statements, %s property/value " +
940
+ "assertions, and %s other assertions>" % (
941
+ len ([ctx for ctx in self .contexts ()]),
942
+ typeLen , quotedLen , literalLen , assertedLen ))
943
+ except Exception :
944
+ return "<Partitioned SQL N3 Store>"
945
+ else :
946
+ return "<Partitioned unopened SQL N3 Store>"
944
947
945
948
def __len__ (self , context = None ):
946
949
""" Number of statements in the store. """
0 commit comments