Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'RawQuery' object has no attribute 'iterator' #15

Closed
mouday opened this issue Jun 3, 2019 · 4 comments
Closed

AttributeError: 'RawQuery' object has no attribute 'iterator' #15

mouday opened this issue Jun 3, 2019 · 4 comments

Comments

@mouday
Copy link

mouday commented Jun 3, 2019

使用大佬的工具运行

mom run -c ./test_mom/cron_config.py
报错了
AttributeError: 'RawQuery' object has no attribute 'iterator'

@mouday
Copy link
Author

mouday commented Jun 3, 2019

具体报错细节为:

Traceback (most recent call last):
  File "/Users/qmp/.virtualenvs/qmpspider/lib/python2.7/site-packages/apscheduler/executors/base.py", line 125, in run_job
    retval = job.func(*job.args, **job.kwargs)
  File "/Users/qmp/.virtualenvs/qmpspider/lib/python2.7/site-packages/mysqlsmom/mysqlsmom.py", line 321, in do_one_task
    query = MyModel.raw(task["stream"]["sql"].replace("?", "%s"), (last_start_time,)).dicts().iterator()
AttributeError: 'RawQuery' object has no attribute 'iterator'

@mouday
Copy link
Author

mouday commented Jun 3, 2019

我的配置文件 cron_config.py

# coding=utf-8

STREAM = "CRON"

# 修改数据库连接
CONNECTION = {
    'host': '127.0.0.1',
    'port': 3306,
    'user': 'root',
    'passwd': '123456'
}

# redis存储上次同步时间等信息
REDIS = {
    "host": "127.0.0.1",
    "port": 6379,
    "db": 0,
    # "password": "password",  # 不需要密码则注释或删掉该行
}

# 一次同步 BULK_SIZE 条数据到elasticsearch,不设置该配置项默认为1
BULK_SIZE = 1

# 修改elasticsearch节点
NODES = [{"host": "127.0.0.1", "port": 9200}]

TASKS = [
    {
        "stream": {
            "database": "demo",  # 在此数据库执行sql语句
            "sql": "select id, name from student where update_time >= ?",  # 将该sql语句选中的数据同步到 elasticsearch
            "seconds": 10,  # 每隔 seconds 秒同步一次,
            "init_time": "2018-08-15 18:05:47"  # 只有第一次同步会加载
        },
        "jobs": [
            {
                "pipeline": [
                    {"set_id": {"field": "id"}}  # 默认设置 id字段的值 为elasticsearch中的文档id
                ],
                "dest": {
                    "es": {
                        "action": "upsert",
                        "index": "demo",   # 设置 index
                        "type": "student"          # 设置 type
                    }
                }
            }
        ]
    }
]

# CUSTOM_ROW_HANDLERS = "./my_handlers.py"
# CUSTOM_ROW_FILTERS = "./my_filters.py"

@m358807551
Copy link
Owner

新建个 py27 的虚拟环境安装吧。

旧环境里 的 peewee 版本跟 mysqlsmom 用到的 peewee 版本不兼容;

@mouday
Copy link
Author

mouday commented Jun 3, 2019

好的大佬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants