Добрый день, появилась проблема, я создал пакет, в __init__ написал
import telebot
from flask import Flask, session
from bot.db import *
app = Flask(__name__)
app.secret_key = 'ddddd'
if __name__ == '__main__':
app.run(debug = True)
db.py выглядит так
from flaskext.mysql import MySQL
from bot import app
app.config['MYSQL_DATABASE_USER'] = 'lie'
app.config['MYSQL_DATABASE_PASSWORD'] = 'zx23ww'
app.config['MYSQL_DATABASE_DB'] = 'telebot'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql = MySQL(app)
connect = mysql.connect()
И появилась проблема, в db.py я не могу импортировать переменную app
* Serving Flask app "bot"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "bot", an ImportError was raised:
Traceback (most recent call last):
File "/home/lietry/sova/callback/venv/lib/python3.6/site-packages/flask/cli.py", line 236, in locate_app
__import__(module_name)
File "/home/lietry/sova/callback/bot/__init__.py", line 3, in <module>
from bot.db import *
File "/home/lietry/sova/callback/bot/db.py", line 2, in <module>
from bot import app
ImportError: cannot import name 'app'
Так вот, как правильно импортировать переменные из __init__.py?