How to use the prettytable.from_db_cursor function in prettytable

To help you get started, we’ve selected a few prettytable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iranzo / stampython / stampy / plugin / autokarma.py View on Github external
logger = logging.getLogger(__name__)
    wordtext = ""

    if not word:
        sql = "select key,value from autokarma ORDER BY key ASC;"
    else:
        string = (word, gid)
        sql = "SELECT key,value FROM autokarma WHERE key='%s' AND gid='%s' ORDER by key ASC;" % string
        wordtext = _("for word %s for gid %s") % (word, gid)

    cur = stampy.stampy.dbsql(sql)

    try:
        # Get value from SQL query
        text = _("Defined autokarma triggers %s:\n") % wordtext
        table = from_db_cursor(cur)
        text = "%s\n```%s```" % (text, table.get_string())

    except:
        # Value didn't exist before
        text = _("%s has no trigger autokarma") % word

    logger.debug(msg=_L("Returning autokarma %s for word %s") % (text, word))
    return text
github iranzo / stampython / stampy / plugin / karma.py View on Github external
try:
            # Get value from SQL query
            value = value[1]

        except:
            # Value didn't exist before, return 0 value
            value = 0
        text = _("`%s` has `%s` karma points.") % (word, value)

    else:
        # if word is not provided, return top 10 words with top karma
        sql = "select word,value,date from karma where gid='%s' ORDER BY value DESC LIMIT 10;" % gid

        text = _("Global rankings:\n")
        cur = stampy.stampy.dbsql(sql)
        table = from_db_cursor(cur)
        text = "%s\n```%s```" % (text, table.get_string())
    logger.debug(msg=_L("Returning karma %s for word %s") % (text, word))
    return text
github rvojcik / iredmail-cli / email-manage-pro.py View on Github external
def print_results(cursor_object):
    """Print results from database in nice table"""
    table = from_db_cursor(cursor_object)
    table.align = 'l'
    print table
github sjml / SimulatorGenerator / SimulatorGeneratorTwitter.py View on Github external
def printQueue():
    persistence.execute("SELECT * FROM queuedRequests")
    tab = prettytable.from_db_cursor(persistence)
    print(tab)
github iranzo / stampython / stampy / plugin / feed.py View on Github external
Lists the feeds defined
    :return: table with feeds stored
    """

    logger = logging.getLogger(__name__)

    sql = "select name,lastchecked,url,interval  from feeds"
    if gid:
        sql = "%s%s" % (sql, " WHERE gid=%s" % gid)
    sql = "%s%s" % (sql, " ORDER BY name ASC;")
    cur = stampy.stampy.dbsql(sql)

    try:
        # Get value from SQL query
        text = _("Defined feeds:\n")
        table = from_db_cursor(cur)
        text = "%s\n```%s```" % (text, table.get_string())
    except:
        text = ""

    logger.debug(msg=_L("Returning feeds"))
    return text
github iranzo / stampython / stampy / plugin / alias.py View on Github external
value = cur.fetchone()

        try:
            # Get value from SQL query
            value = value[1]

        except:
            # Value didn't exist before, return 0 value
            value = 0
        text = _("%s has an alias %s") % (word, value)

    else:
        sql = "select key,value from alias WHERE gid='%s' ORDER BY key ASC;" % gid
        cur = stampy.stampy.dbsql(sql)
        text = _("Defined aliases:\n")
        table = from_db_cursor(cur)
        text = "%s\n```%s```" % (text, table.get_string())
    logger.debug(msg=_L("Returning aliases %s for word %s for gid %s") % (text, word, gid))
    return text
github iranzo / stampython / stampy / plugin / stats.py View on Github external
sql = "select type,id,name,date,count from stats WHERE type='%s'" % type

        if name:
            string = "%" + "%s" % name + "%"
            sql = sql + " and " + key + "like '%s'" % string
    else:
        sql = "select type,id,name,date,count from stats"

        if name:
            string = "%" + "%s" % name + "%"
            sql = sql + " WHERE " + key + " like '%s'" % string

    sql = sql + " ORDER BY count DESC LIMIT 10"

    cur = stampy.stampy.dbsql(sql)
    table = from_db_cursor(cur)
    text = _("Defined stats:\n")
    text = "%s\n```%s```" % (text, table.get_string())
    logger.debug(msg=_L("Returning stats %s") % text)
    return text