No viable alternative at input mongodb

SyntaxError: no viable alternative at input ‘"{genPath}/{dataTag[0][‘name’]}"’ (, line 98)

Code:

`import json

filePath = 'E:\\tags.json'        
tagPaths = ["[default]"]
recursive = True
 
system.tag.exportTags(filePath, tagPaths, recursive)    

#Load JSON file
with open("tags.json") as f:
    data = json.load(f)
        
#Load XML template of GroupConfig from a text file
with open("template.txt", 'r') as f:
    TXML = f.read()
    
genPath = "" 

#Code to generate the path of the GroupConfig
dataX = data
while True:
    if dataX["tagType"] == "Folder":
        genPath += dataX["name"] + "/"
    
    try:
        dataX = dataX["tags"][0]
    except:
        break
genPath = genPath[:-1]
    
#Code to get the list of tags
dataTags = []
dataX = data
for lvl in genPath.split("/"):
    if dataX["name"] == lvl:
        if len(genPath.split("/")) == genPath.split("/").index(lvl) + 1:
            dataTags = dataX["tags"]
            break
        else:
            dataX = dataX["tags"][0]
    
tempDataTags = []        
for dataTag in dataTags:
    tempDataTags.append([dataTag, genPath])
dataTags = tempDataTags
            
#Checking for nested tags
while True:
    for dataTag in dataTags:
        if dataTag[0]["tagType"] == "Folder":
            for nDataTag in dataTag[0]["tags"]:
                dataTags.append([nDataTag, dataTag[1] + "/" + dataTag[0]["name"]])
            dataTags.remove(dataTag)
            newAdded = True
        else:
            newAdded = False
            
    if newAdded == False:
        break
    else:
        continue
            

#base XML structure with a vaiable '[[[TEMP]]]' to replace with the data
finalXML = "<Project><Groups>[[[TEMP]]]</Groups></Project>"

#EngHigh snippet, well be used to insert later in the code
engHigh = """<ItemConfig name="EngHigh" typeId="3">
          <Property name="TARGET_DATA_TYPE">5</Property>
          <Property name="DRIVING_TAG_PATH">[default]Enterprise 1/Site 1/Area 1/Line 1/Machine 1/Tag 1.EngHigh</Property>
          <Property name="TARGET_NAME">EngHigh</Property>
          <Property name="TARGET_TYPE">1</Property>
       </ItemConfig>"""


tempXML = "" #Temp vaiable to append groupConfig of each tags

#Looping Tags, generating GroupConfig for each tags, and appending to tempXML
for dataTag in dataTags:
    TEMP = TXML
    genPath = dataTag[1]
    
   
    try:
            #Taking historyProvider value to insert into DATA_SOURCE
        HP = dataTag[0]["historyProvider"]
        TEMP = TEMP.replace("[[[--SOURCE--]]]", HP)
   
        
        #if EngHigh is in the tags, it will be added to the XML
        try:
            EH = dataTag[0]["engHigh"]
            TEMP = TEMP.replace("[[[--ENGHIGH--]]]", engHigh)
        except:
            TEMP = TEMP.replace("[[[--ENGHIGH--]]]", "")
            
        #Inserting PATH to the XML
        TEMP = TEMP.replace("[[[--PATH--]]]", f"{genPath}/{dataTag[0]['name']}")
        TEMP = TEMP.replace("[[[--GCPATH--]]]", f"ContextualizedData/{genPath}")
        
        #Inserting NAME to the XML 'GroupConfig'
        TEMP = TEMP.replace("[[[--GCNAME--]]]", dataTag[0]["name"])
        
        #Appending to tempXML, generated GroupConfig of a tag
        tempXML += TEMP
        
    except KeyError:
        pass

#Adding all Generated GroupConfig to the finalXML
finalXML = finalXML.replace("[[[TEMP]]]", tempXML)

#Saving the XML String as XML file
with open("project.xml", "w") as f:
    f.write(finalXML)

New

[RESOLVED] CASSANDRA : line 0:-1 no viable alternative at input ''

Sameera Nelson January 24, 2018 Cassandra, Database, Database Exception

No viable alternative at input mongodb



Cassandra Query Issue

When querying for data in Cassandra, The following error was thrown in DataStax Studio,

SELECT * FROM XXXXX WHERE name = "xxxxx"
line 0:-1 no viable alternative at input '<EOF>'

Cause of the Issue

It seems the issue is using "" for the String fields.

Fix 

Instead of double quotes (""), using single quotes ('') will resolve the issue.

SELECT * FROM XXXXX WHERE name = 'xxxxx'
Image : https://pixabay.com/en/wires-cables-inputs-outputs-audio-354065/





Read more

Subscribe via email

Share This:

Facebook Twitter Google+ Pinterest Linkedin

Database Exception

By Sameera Nelson atJanuary 24, 2018

Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest

Labels: Cassandra, Database, Database Exception