Ejemplo n.º 1
0
    def GET(self):
        global myCurrentQueries
        DBLinks = DB.doOpen(C.SQLCONFIG)
        myInput = web.input(STARTRECNUM=0, QUERYNUM=1)
        if myInput[C.QUERYNUM] != myCurrentQueries[C.QUERYNUM]:
            myCurrentQueries = C.QUERIESINGLOBALDEFAULTS
        myCurrentQueries[C.STARTRECNUM] = myInput[C.STARTRECNUM]
        myCurrentQueries[C.QUERYNUM] = myInput[C.QUERYNUM]
        myCurrentQueries[C.ROWNUM] = 0
        SQLStr = f"""
select * from {C.QUERIESINTABLENAME}
where {C.RID} = {myCurrentQueries[C.QUERYNUM]};"""
        SQLRowsDict = DB.getSqlOne(DBLinks, SQLStr)
        myCurrentQueries = DB.upgradeDBToGQI(SQLRowsDict,
                                             C.QUERIESINGLOBALDEFAULTS)
        outStr = sendMyHeader(
            f"{myCurrentQueries[C.QUERIESINTITLE]}  {__file__}")
        SQLStr = f"""
{myCurrentQueries[C.SQLSELECT]}
{myCurrentQueries[C.SQLWHERE]}
{myCurrentQueries[C.SQLGROUPBY]} 
{myCurrentQueries[C.SQLORDERBY]}
"""
        SQLStr += DB.saneMakeSqlLimitStr(myCurrentQueries[C.STARTRECNUM]) + ";"
        SQLRowsDict, SQLNumRows = DB.getSqlAll(DBLinks, SQLStr)
        myCurrentQueries[C.NUMROWS] = SQLNumRows
        myCurrentQueries[C.PGNUM] = int(
            int(myCurrentQueries[C.STARTRECNUM]) / C.NUMROWSPERPG) + 1
        myCurrentQueries[C.OFPGS] = int(
            int(myCurrentQueries[C.NUMROWS]) / C.NUMROWSPERPG) + 1
        # theseRows = DB.upgradeDBToGQIMany(SQLRowsDict, C.QUERIESINGLOBALDEFAULTS)
        outStr += "<table>\n"
        for thisRow in SQLRowsDict:
            thisRow = DB.DTfixThisLineToDisplay(thisRow)
            lastRow = thisRow
            outStr += DB.makeTableRow(thisRow, myCurrentQueries, 0)
            myCurrentQueries[C.ROWNUM] += 1
        outStr += DB.makeTableRow(lastRow, myCurrentQueries, 1)
        outStr += """
		</table>
		<span class="fp">bottom of the page</span>
	</body>
</html>
"""
        return outStr
Ejemplo n.º 2
0
    def GET(self):
        global myCurrentQueries
        DBLinks = DB.doOpen(C.SQLCONFIG)
        myInput = web.input(STARTRECNUM=0, QUERYNUM=C.DEFQUERYNUM)
        # C.QUERYLOADED (-1) if from select the parts
        # C.QUERYFROMPRESET (1) if from presets
        # C.QUERYEMPTY (0) if anything else
        if myInput[C.QUERYNUM] != myCurrentQueries[C.QUERYNUM]:
            myCurrentQueries = C.QUERIESINDEFAULTS()
            myCurrentQueries[C.QUERYNUM] = myInput[C.QUERYNUM]
            # C.QUERYLOADED if set by any of the query building parts,
            # C.QUERYFROMPRESET if loaded from a preset
            # C.QUERYEMPTY if "empty"
            myCurrentQueries[C.ISLOADED] = C.QUERYEMPTY
        myCurrentQueries[C.STARTRECNUM] = myInput[C.STARTRECNUM]
        myCurrentQueries[C.QUERYNUM] = myInput[C.QUERYNUM]
        myCurrentQueries[C.ROWNUM] = 0
        if myCurrentQueries[C.ISLOADED] != C.QUERYLOADED:
            SQLStr = f"""
select * from {C.QUERIESINTABLENAME}
where {C.RID} = {myCurrentQueries[C.QUERYNUM]};"""
            SQLRowsDict = DB.getSqlOne(DBLinks, SQLStr)
            myCurrentQueries = DB.upgradeDBToGQI(SQLRowsDict, myCurrentQueries)
            myCurrentQueries[C.ISLOADED] = 1
        C.REGIONNAMESDICT[C.REGION0NAME] = myCurrentQueries[C.REGION0NAME]
        C.REGIONNAMESDICT[C.REGION1NAME] = myCurrentQueries[C.REGION1NAME]
        C.REGIONNAMESDICT[C.REGION2NAME] = myCurrentQueries[C.REGION2NAME]
        C.REGIONNAMESDICT[C.REGION3NAME] = myCurrentQueries[C.REGION3NAME]
        C.REGIONDESCRIPTIONSDICT[C.REGION0DESCRIPTION] = myCurrentQueries[
            C.REGION0DESCRIPTION]
        C.REGIONDESCRIPTIONSDICT[C.REGION1DESCRIPTION] = myCurrentQueries[
            C.REGION1DESCRIPTION]
        C.REGIONDESCRIPTIONSDICT[C.REGION2DESCRIPTION] = myCurrentQueries[
            C.REGION2DESCRIPTION]
        C.REGIONDESCRIPTIONSDICT[C.REGION3DESCRIPTION] = myCurrentQueries[
            C.REGION3DESCRIPTION]
        outStr = sendMyHeader(f"""{myCurrentQueries[C.QUERIESINTITLE]}""",
                              f"""styleChunk.css""")
        SQLStr = f"""
{myCurrentQueries[C.SQLSELECT]}
{myCurrentQueries[C.SQLWHERE]}
{myCurrentQueries[C.SQLGROUPBY]}
{myCurrentQueries[C.SQLHAVING]}
{myCurrentQueries[C.SQLORDERBY]}
"""
        SQLStr += DB.saneMakeSqlLimitStr(myCurrentQueries[C.STARTRECNUM]) + ";"
        SQLRowsDict, SQLNumRows = DB.getSqlAll(DBLinks, SQLStr)
        myCurrentQueries[C.NUMROWS] = SQLNumRows
        myCurrentQueries[C.PGNUM] = int(
            int(myCurrentQueries[C.STARTRECNUM]) / C.NUMROWSPERPG) + 1
        myCurrentQueries[C.OFPGS] = int(
            int(myCurrentQueries[C.NUMROWS]) / C.NUMROWSPERPG) + 1
        # theseRows = DB.upgradeDBToGQIMany(SQLRowsDict, C.QUERIESINGLOBALDEFAULTS)
        outStr += f"""
<span class="labels"><br />current SQLStr<br />{SQLStr}<br /></span><br />

"""
        outStr += "<table>\n"
        if myCurrentQueries[C.NUMROWS] < 1:
            outStr += f"""
<tr>
	<td class="close0r0">no entries found</td>
	<td class="close3r0"><a href="menu">click for the menu</a></td>
</tr>
<tr>
	<td class="close3r1"><a href="presets">presets</a></td>
	<td class="close2r0"><a href="quakes/?QUERYNUM={C.DEFQUERYNUM}&STARTRECNUM=0">
		for the default preset</a></td>
</tr>
<tr>
	<td class="close2r1"><a href="stop">stop the server</a></td>
	<td class="close1r0">{TDS.nowStrSql()}</td>
</tr>
</table>
</body>
</html>

"""
            return outStr
        for thisRow in SQLRowsDict:
            thisRow = DB.DTfixThisLineToDisplay(thisRow)
            lastRow = thisRow
            outStr += DB.makeTableRow(thisRow, myCurrentQueries, 0)
            myCurrentQueries[C.ROWNUM] += 1
        outStr += DB.makeTableRow(lastRow, myCurrentQueries, 1)
        outStr += f"""
		</table>
		{DB.makeDistance()}
		<span class="fp">bottom of the page</span>
	</body>
</html>
"""
        return outStr