from sqlmodel import create_engine

from pyflarum.database.session import FlarumDatabase
from pyflarum.database.flarum.core.users import DB_User


ENGINE = create_engine('sqlite:///tests/database/database.db')
DATABASE = FlarumDatabase(engine=ENGINE)



if __name__ == "__main__":
    with DATABASE:
        for user in DATABASE.generic_filter(DB_User, id=1).all():
            if user.discussions:
                print(user.username, ':', sep='')

                for discussion in user.discussions:
                    print('•', discussion.title)

            else:
                print(user.username, '(no discussions)')

sqlmodel.create_engine pyflarum.database.session.FlarumDatabase
[((156, 209), 'sqlmodel.create_engine', 'create_engine', (['"""sqlite:///tests/database/database.db"""'], {}), "('sqlite:///tests/database/database.db')\n", (169, 209), False, 'from sqlmodel import create_engine\n'), ((221, 250), 'pyflarum.database.session.FlarumDatabase', 'FlarumDatabase', ([], {'engine': 'ENGINE'}), '(engine=ENGINE)\n', (235, 250), False, 'from pyflarum.database.session import FlarumDatabase\n')]