Beispiel #1
0
def dropNode(node):
    nGQL=f"""
     USE blog;
     DROP  TAG {node.nodeType};
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #2
0
def DESCRIBEEDGE(edgeName):
    nGQL="""
    USE blog;
    DESCRIBE tag MainCategory;
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #3
0
def getNode(node):
    nGQL=f"""
    USE blog;
    DESCRIBE tag {node.nodeType};
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #4
0
def fetchNodeByName(node):
    nGQL=f"""
     USE blog;
     FETCH PROP ON MainCategory "{node.nodeIdByHash}";
    """
    query_resp= runGql(nGQL)
    return query_resp
Beispiel #5
0
def dropNodeByName(node):
    nGQL=f"""
     USE blog;
     DELETE VERTEX "{node.nodeIdByHash}";
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #6
0
def createNode(node):
    propertiesString=""
    for attr,attrType in node.properties.items():
        propertiesString+=f"{attr} {attrType},"
    nGQL=f"""
     USE blog;
     CREATE TAG {node.nodeType}({propertiesString});
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #7
0
def alertNodeAddAttr(node):
    propertiesString=""
    for attr,attrType in node.properties.items():
        propertiesString+=f"{attr} {attrType},"
    propertiesString=delLastChar(propertiesString)
    nGQL=f"""
     USE blog;
     ALTER TAG {node.nodeType} ADD ({propertiesString});
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #8
0
def DESCRIBENODE(nodeType):
    nGQL=f"""
    USE blog;
    DESCRIBE tag {nodeType};
    """
    query_resp = runGql(nGQL)
    print(query_resp)
    for attr in query_resp['data'].rows:
        attrNames = bytes.decode(attr.values[0].get_sVal())
        attrType = bytes.decode(attr.values[1].get_sVal())
        Typedict[attrNames]=attrType
    return query_resp
Beispiel #9
0
def insertNodeByName(node):
    attrString=""
    attrValuesString=""
    for attr,attrValues in node.properties.items():
        attrString+=f"{attr},"
        try:
            attrType=Typedict[attr]
        except:
            DESCRIBENODE(node.nodeType)
            attrType=Typedict[attr]
        if attrType=="string":
            attrValuesString+=f'"{attrValues}",'
        else:
            attrValuesString+=f'{attrValues},'

    attrString,attrValuesString=map(delLastChar,[attrString,attrValuesString])

    nGQL=f"""
     USE blog;
     INSERT VERTEX {node.nodeType}({attrString}) VALUES "{node.nodeIdByHash}":({attrValuesString});
    """
    query_resp = runGql(nGQL)
    return query_resp
Beispiel #10
0
def createGraph(dbName):
    query_resp = runGql(f'CREATE SPACE {dbName}')
    return query_resp
Beispiel #11
0
def getAllGraph():
    query_resp = runGql('SHOW SPACES')
    return query_resp
Beispiel #12
0
def deletGraph(dbName):
    query_resp = runGql(f'DROP  SPACE {dbName}')
    return query_resp
Beispiel #13
0
async def runNgql(nGql):
    result = runGql(nGql)
    return result