Home>

I have a bot telegram , written in aiogram , in which work with the database is displayed in a separate file in a separate class. In the rest of the files, I need access to this database.

If I need access to the database in several files, then I need to make a connection to this file and connect to the database in each file, or is it better to make this connection in some separate file and then import this variable?

Well, it's probably more convenient to make the connection in a separate class and then work through this class for all your classes.

CrazyElf2021-11-20 09:57:14

Yes, I have done it now, and I think then it will not affect the efficiency of the bot.

b0shka2021-11-20 10:18:14