小编Bhu*_*han的帖子

在谷歌表单中提交时访问用户输入的数据

我有一个google表单,其中包含以下两个字段:

  • 电子邮件地址: - 文本框
  • 工具: - 一个单选按钮
    • 工具1
    • 工具2
    • 工具3

用户将输入他的电子邮件地址并选择工具并单击"提交".我希望看到以下消息:

谢谢你的回复.已发送电子邮件至您输入的电子邮件地址以下载所选工具.

我在脚本编辑器中有以下代码

    function emailFormSubmission() {
        var form = FormApp.getActiveForm();//the current form
        var dest_id = form.getDestinationId(); //the destination spreadsheet where form responses are stored
        var ss = SpreadsheetApp.openById(dest_id);//open that spreadsheet
        var theFormSheet = ss.getSheets()[0]; //read the first sheet in that spreadsheet
        var row = theFormSheet.getLastRow(); //get the last row
        var emailid = theFormSheet.getRange(row,2,1,1).getValue();//get column 2 corresponding to the email id. column 1 is timestamp. so, skip …
Run Code Online (Sandbox Code Playgroud)

google-apps google-apps-script google-forms

8
推荐指数
1
解决办法
7101
查看次数

具有多个数据库的 SQLAlchemy 因重复创建索引而出错

我们有一个包含两个表的 postgres 数据库Models,并且Drives我们使用 sqlalchemy 创建查询来分析这些表中的数据。

Models表具有以下架构:

CREATE TABLE models (
    id SERIAL PRIMARY KEY,
    vendor_name character varying(32) NOT NULL,
    model character varying(32) NOT NULL,
    drive_capacity bigint NOT NULL
);

-- Indices -------------------------------------------------------

CREATE UNIQUE INDEX models_pkey ON models(id int4_ops);
CREATE INDEX idx_models_vendor_name ON models(vendor_name text_ops);
CREATE INDEX idx_models_model ON models(model text_ops); 
Run Code Online (Sandbox Code Playgroud)

Models并由以下类表示tables.py

class Models(Base, DeferredReflection):
    __tablename__ = "models"
    id = Column("id", Integer, primary_key=True)
Run Code Online (Sandbox Code Playgroud)

Drives表具有以下架构:

CREATE TABLE drives (
    id SERIAL PRIMARY …
Run Code Online (Sandbox Code Playgroud)

python sqlite postgresql sqlalchemy

5
推荐指数
0
解决办法
597
查看次数

使用 pytest-xdist 跨主节点和工作节点访问共享资源

我试图在主节点和工作节点之间共享数据库中的随机条目列表(我对共享资源的定义),并使用 pytest-xdist 并行化测试。我的代码遵循以下结构:

## in conftest.py
def get_db_entries():
   connect to db
   run a query with group by and random
   returns one random entry per group as a list of dictionaries.
Run Code Online (Sandbox Code Playgroud)

我改编了https://hackebrot.github.io/pytest-tricks/shared_directory_xdist/提供的建议,以在主节点和工作节点之间共享数据库条目:

# in conftest.py
def pytest_configure(config):
    if is_master(config):
        # share db_entries across master and worker nodes.
        config.db_samples = get_db_entries()

def pytest_configure_node(node):
    """xdist hook"""
    node.slaveinput['db_entries'] = node.config.db_samples

def is_master(config):
    """True if the code running the given pytest.config object is running in a xdist master
    node or not running xdist at …
Run Code Online (Sandbox Code Playgroud)

python pytest xdist

2
推荐指数
1
解决办法
3132
查看次数