The exe file of python app creates the database but doesn't create tables in some PCs

Viewed 97

I have implemented an application using python, PostgreSQL, pyqt5, Sqlalchemy and made an execution file for it through pyInstaller.

I tried installing this app on some laptops which had PostgreSQL 13 installed already on them. But there is a problem.

In some Laptops it's Ok and everything runs successfully and the database is created along with its tables on PostgreSQL, we can check it through Pgadmin 4 and we can work with the application successfully, but in some other laptops the database is created but not its tables and so the console stops and nothing appears and when we check Pgadmin there only is the database name not its tables.

P.S: the systems are Windows 10 and Windows 7.

I have no idea what to check or what to do I would appreciate it if anyone can give me any ideas.

the following code is base.py:

    from sqlalchemy import create_engine
    from sqlalchemy.ext.declarative import declarative_base
    from sqlalchemy.orm import sessionmaker
    from sqlalchemy_utils import database_exists, create_database
    from sqlalchemy import Column
    engine = create_engine('postgresql://postgres:123@localhost:5432/db23')
    if not database_exists(engine.url):
        create_database(engine.url)
    Session = sessionmaker(bind=engine)
    Base = declarative_base()

and the following function is called in initializer function of the app:

    def the_first_time_caller(self):
        session = Session()
        # 2 - generate database schema
        Base.metadata.create_all(engine)  # create tables in the database
        session.commit()
        session.close()
1 Answers

with Updating Python and downgrading Sqlalchemy, It runs successfully now.

Related