Skip to content

--configuration-path doesn't seem to work #46

Closed
@jessejoe

Description

@jessejoe

I know --configuration-path was added relatively recently and isn't in an official release yet, but I don't think it works as intended.

The issue seems to be that the _engine object in database.py is created when database is imported at the top of command.py, which is before main() is actually ran. This is shown by setting some breakpoints:

root@fa952bf0b0fe:~# pinnwand --configuration-path pinnwand.toml http
> /usr/local/lib/python3.7/site-packages/pinnwand/database.py(29)<module>()
-> _engine = create_engine(configuration.database_uri)
(Pdb) c
> /usr/local/lib/python3.7/site-packages/pinnwand/command.py(39)main()
-> setattr(configuration, key, value)
(Pdb) n
> /usr/local/lib/python3.7/site-packages/pinnwand/command.py(37)main()
-> for key, value in configuration_file.items():
(Pdb) configuration.database_uri
'sqlite:///tmp/pinnwand.db'
(Pdb) c
> /usr/local/lib/python3.7/site-packages/pinnwand/command.py(47)http()
-> database.Base.metadata.create_all(database._engine)
(Pdb) database._engine
Engine(sqlite:///:memory:)

Notice configuration.database_uri was set properly to '/tmp/pinnwand.db' inside main(), but inside http() database._engine is still set to Engine(sqlite:///:memory:)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions