toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.1k stars 172 forks source link

AttributeError: 'str' object has no attribute 'items' #471

Open rudonx opened 11 months ago

rudonx commented 11 months ago

PGSync version: pgsync --version Version: 2.5.0

Postgres version: 12.9

Elasticsearch version: 7.10.2

Redis version: 6.0 Python version: python3 --version Python 3.8.13 Problem Description: Hi developer, follow the "readme" guide, create three table(book,bookauthor and author) and run bootstrap --config command, the error is below:

Error Message (if any):

(my_py_env)  bootstrap --config schema.json 
Traceback (most recent call last):
  File "/root/miniconda3/envs/my_py_env/bin/bootstrap", line 69, in <module>
    main()
  File "/root/miniconda3/envs/my_py_env/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/root/miniconda3/envs/my_py_env/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/root/miniconda3/envs/my_py_env/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/miniconda3/envs/my_py_env/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/root/miniconda3/envs/my_py_env/bin/bootstrap", line 57, in main
    for document in config_loader(config):
  File "/root/miniconda3/envs/my_py_env/lib/python3.8/site-packages/pgsync/utils.py", line 141, in config_loader
    for key, value in document.items():
AttributeError: 'str' object has no attribute 'items'
rudonx commented 11 months ago

Is it a env issue, how to resolve it. Thank you

toluaina commented 11 months ago

can you share your schema config if possible please?

jvanderen1 commented 6 months ago

I am also seeing this issue. I modified pgsync/utils.py to add a print statement just before the problematic line:

print("doc:", doc)

I then saw the following:

doc: index

I think it's because I am following the example from "Schema" and have formatted it as:

{
  "index": "foo",
  "nodes": {
    ...
  }
}