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: 'pg_engine' object has no attribute 'pgsql_cur' #98

Closed
stereobooster opened this issue Apr 19, 2019 · 8 comments
Closed
Assignees
Labels

Comments

@stereobooster
Copy link

stereobooster commented Apr 19, 2019

Hi there!

I'm trying to configure replica from MySQL to Postgres with docker-compose. I created two db images and separate image for chameleon

FROM python:3.7-alpine

RUN \
 apk add --no-cache postgresql-libs && \
 apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
 pip install pg_chameleon --no-cache-dir && \
 apk --purge del .build-deps && \
 chameleon set_configuration_files

COPY wait-for.sh /bin
VOLUME /root/.pg_chameleon

ENTRYPOINT sh -c '/bin/wait-for.sh db:3306 -- /bin/wait-for.sh pg:5432 -- chameleon init_replica --config default --source mysql --debug'

When I run it I get this error: AttributeError: 'pg_engine' object has no attribute 'pgsql_cur'.

My guess is that I need to install chameleon inside Postgres image instead of separate image. Do you have any instructions/advices on how to use chameleon with Docker?

Source code is here https://github.com/stereobooster/headless-cms-comparison/tree/master/directus-chameleon-hasura

@the4thdoctor
Copy link
Owner

the error means the connection to postgresql is not successfuly. did you enable postgres to accept the connections from other hosts? what the postgresql log says?

@the4thdoctor the4thdoctor self-assigned this Jun 5, 2019
@mbrgm
Copy link

mbrgm commented Sep 10, 2019

@stereobooster I had the same issue and from the repo you linked it appears to be for identical reasons:

  File "/usr/local/lib/python3.7/site-packages/pg_chameleon/lib/global_lib.py", line 115, in __init__
    self.pg_engine.type_override = self.config["type_override"]
KeyError: 'type_override'

It appears to me that you have to specify an empty dict in the yaml file when you do not want to have type override. The same goes for limit_tables, skip_tables and grant_select_to (lists here).

@the4thdoctor Maybe a check for the key or retrieval of the key with a default value on nonexistence would help avoid this kind of error?

Edit: Meant to write empty dict, not empty list: type_override: {}

@szcc
Copy link

szcc commented Aug 10, 2020

@the4thdoctor
Hi there!

I'm trying to configure replica from MySQL to Postgres.
"chameleon add_source --config default --debug"
I got error:
"You must specify a source name with the argument --source"
I thought my source already in the default config file ???

@szcc
Copy link

szcc commented Aug 10, 2020

I updated the schema mapping in the config file and it works

@cjrutherford
Copy link

I'm actually having the same issue, and I've tried it with the empty dicts, but nothing. I think it may be related to how the source schema in the schema mappings needs to be escaped (contains a -)

How would one properly escape that?

@the4thdoctor
Copy link
Owner

can you provide an example for your schema_mappings?
I'll try to reproduce the issue.
Thanks

@cjrutherford
Copy link

cjrutherford commented Oct 8, 2020

I want everything in the database, so I just put it in as

    schema_mappings:
      one-database: one_database
    limit_tables: {}
    skip_tables: {}
    grant_select_to:
      - usr_readonly
    lock_timeout: "120s"
    my_server_id: 100
    replica_batch_size: 10000
    replay_max_rows: 10000
    batch_retention: '1 day'
    copy_max_memory: "300M"
    copy_mode: 'file'
    out_dir: /tmp
    sleep_loop: 1
    on_error_replay: continue
    on_error_read: continue
    auto_maintenance: "disabled"
    gtid_enable: false
    type: mysql
    skip_events: {}
    keep_existing_schema: Yes

EDIT: the MySQL database is named one-database and the PSQL database is one_database and I've also tried it with quotes around the one with the -

UPDATE: I've abandoned my plan to use this. thanks for the offer to assist though.

@the4thdoctor
Copy link
Owner

Thanks. Will try to reproduce the error.

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

No branches or pull requests

5 participants