本文整理汇总了Python中drive.Drive.create_sheet方法的典型用法代码示例。如果您正苦于以下问题:Python Drive.create_sheet方法的具体用法?Python Drive.create_sheet怎么用?Python Drive.create_sheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类drive.Drive
的用法示例。
在下文中一共展示了Drive.create_sheet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FantasyDB
# 需要导入模块: from drive import Drive [as 别名]
# 或者: from drive.Drive import create_sheet [as 别名]
#.........这里部分代码省略.........
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
def stats_avg_query(self):