当前位置: 首页>>代码示例>>Python>>正文


Python Drive.login方法代码示例

本文整理汇总了Python中drive.Drive.login方法的典型用法代码示例。如果您正苦于以下问题:Python Drive.login方法的具体用法?Python Drive.login怎么用?Python Drive.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在drive.Drive的用法示例。


在下文中一共展示了Drive.login方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FantasyDB

# 需要导入模块: from drive import Drive [as 别名]
# 或者: from drive.Drive import login [as 别名]

#.........这里部分代码省略.........
                R integer, HR integer, RBI integer, SB integer, AVG real,
                W integer, SV integer, K integer, ERA real, WHIP real);
        """ % (table_name, table_name))

    def insert(self, sql, data=None):
        if data is None:
            self.c.execute(sql)
        else:
            for line in data:
                self.c.execute(sql, line)
        self.con.commit()

    def add_teams(self, teams):
        self.insert("INSERT INTO team VALUES (?, ?, ?, ?)", teams)

    def add_matchups(self, matchups):
        self.insert("INSERT INTO matchup VALUES(?, ?, ?)", matchups)

    def add_stats(self, stats):
        sql = "INSERT INTO week_stats ("
        sql += ", ".join(stats.keys())
        sql += ") VALUES("
        sql += ", ".join(["?"] * len(stats)) + ")"
        self.insert(sql, [tuple(stats.values())])

    def save_data(self, data, name):
        # Save to file
        f = open("export/" + name + ".txt", "w", encoding="utf-8")
        f.write(data)
        f.close()

        # Save to Google Drive
        if self.drive is not None:
            self.drive.login()
            self.drive.create_sheet(name, data)

    def nb_weeks(self):
        sql = "SELECT DISTINCT COUNT(*) FROM week_stats GROUP BY team_id"
        return self.c.execute(sql).fetchone()[0]

    def get_select(self, aggregate="AVG", real_only=True, use_alias=True,
                   use_round=True, as_string=True, table_alias=""):
        columns = OrderedDict({})
        if len(table_alias):
            table_alias += "."
        for cat, conf in self.cats_conf.items():
            if real_only and not conf["real"]:
                continue
            expr = "$(" + cat + ")" if "expr" not in conf else conf["expr"]
            col = expr.replace("$(", aggregate + "(" + table_alias)
            if use_round:
                col = self.apply_round(cat, col)
            if use_alias:
                col = self.apply_alias(cat, col)

            columns[cat] = col

        return ", ".join(columns.values()) if as_string else columns

    def apply_round(self, cat, expr):
        precision = str(self.cats_conf[cat]["precision"])
        return "round(" + expr + "," + precision + ")"

    def apply_alias(self, cat, expr):
        return expr + " AS " + cat
开发者ID:donplei,项目名称:fantasyDB,代码行数:69,代码来源:db.py


注:本文中的drive.Drive.login方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。