jeffknupp / jeffknupp/sandman2
Error creating backref
- Dominant language
- Python
- Stars
- 2k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to use this with Apache Guacamole mysql database. I am getting the below error when running sandman2ctl
Traceback (most recent call last):
File "/usr/local/bin/sandman2ctl", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/sandman2/__main__.py", line 51, in main
app = get_app(args.URI, read_only=args.read_only, schema=args.schema)
File "/usr/local/lib/python3.8/site-packages/sandman2/app.py", line 60, in get_app
_reflect_all(exclude_tables, admin, read_only, schema=schema)
File "/usr/local/lib/python3.8/site-packages/sandman2/app.py", line 139, in _reflect_all
register_model(cls, admin)
File "/usr/local/lib/python3.8/site-packages/sandman2/app.py", line 156, in register_model
cols = list(cls().__table__.primary_key.columns)
File "", line 2, in __init__
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/instrumentation.py", line 373, in _new_state_if_none
state = self._state_constructor(instance, self)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 855, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/instrumentation.py", line 199, in _state_constructor
self.dispatch.first_init(self, self.class_)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/event/attr.py", line 297, in __call__
fn(*args, **kw)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/mapper.py", line 3341, in _event_on_first_init
configure_mappers()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/mapper.py", line 3229, in configure_mappers
mapper._post_configure_properties()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/mapper.py", line 1947, in _post_configure_properties
prop.init()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/interfaces.py", line 196, in init
self.do_init()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/relationships.py", line 1864, in do_init
self._generate_backref()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/relationships.py", line 2069, in _generate_backref
raise sa_exc.ArgumentError(
sqlalchemy.exc.ArgumentError: Error creating backref 'guacamole_user_group_collection' on relationship 'guacamole_user_group.guacamole_entity_collection': property of that name exists on mapper 'mapped class guacamole_entity->guacamole_entity'
The dockerfile I use to containerize the app is this:
FROM python:3-alpine
RUN pip install sandman2 mysql-connector-python
CMD ["sandman2ctl", "mysql+mysqlconnector://guacamole:axway123@172.17.0.1/guacamole"]
EXPOSE 5000
The db schema for reference can be generated with the below command:
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > initdb.sql
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the failure with sandman2ctl against the Apache Guacamole MySQL schema, then inspect sandman2/app.py, especially _reflect_all and register_model, alongside the SQLAlchemy mapper traceback. Done means the schema can be reflected without the guacamole_entity backref collision and sandman2ctl starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python, sqlalchemy
- Domain
- backend-api-design, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100