I am working on a python app that connects to a few different databases. I would like different packages in my project to be able to use the database functions. Instead of creating database logic in each of the packages, how can I create a "Global" package that I can use? Here is an example of the structure I'm thinking of using:
main.py
package1/
__init__.py
stuff1.py
stuff2.py
package2/
__init__.py
moar1.py
moar2.py
database/
__init__.py
dbfunctions.py
I would like to be able to use the database functions in the stuff and moar files without calling them from main.py. I would like to be able to write the database logic, sql, etc in the packages and run them independently based on calls from main.py.
Question: How do I import the database functions into package1 and package2? I would like to import the database items from the sibling directory.
(also, I am way more familiar with using PHP and just starting out with python, so if I am going down completely down the wrong path I haven't started writing the app yet. totally open to different structure suggestions.)