malnvenshorn / OctoPrint-FilamentManager

OctoPrint plugin to manage your filament inventory
GNU Affero General Public License v3.0
131 stars 60 forks source link

Preping connection to external database. Silently restore broken conn… #145

Open shvbox opened 5 years ago

shvbox commented 5 years ago

…ection. Fix wrong id when inserting with external database.

What does this PR do and why is it necessary?

  1. Silently reconnect to external database when connection was broken. Use of _pool_preping option of SqlAlchemy 1.2
  2. When connected to external PostgreSql database result.lastrowid allways returns 0. With SQLite all is fine. Using _result.inserted_primarykey[0] works as expected for both databases.

How was it tested? How can it be tested by the reviewer?

Tested on my farm.

Any background context you want to provide?

https://stackoverflow.com/questions/23747742/sqlalchemy-session-reconnect https://stackoverflow.com/questions/8589674/sqlalchemy-getting-the-id-of-the-last-record-inserted

What are the relevant tickets if any?

108

Screenshots (if appropriate)

Further notes

Changed requiremens for SqlAlchemy version >= 1.2 Changed plugin version