from models.base_model import db
from models.user_model import UserModel
from models.waifu_model import WaifuModel
from models.waifu_message_model import WaifuMessageModel


def create_tables():
    db.connect()
    db.create_tables((
        UserModel,
        WaifuModel,
        WaifuMessageModel,
    ), True)
    db.manual_close()

if __name__ == '__main__':
    create_tables()

from models.base_model import db
from models.user_model import UserModel
from models.waifu_model import WaifuModel
from models.waifu_message_model import WaifuMessageModel


def create_tables():
    db.connect()
    db.create_tables((
        UserModel,
        WaifuModel,
        WaifuMessageModel,
    ), True)

if __name__ == '__main__':
    create_tables()
    db.manual_close()

Fix close connection only when called as script.
Fix close connection only when called as script.

  from models.base_model import db
  from models.user_model import UserModel
  from models.waifu_model import WaifuModel
  from models.waifu_message_model import WaifuMessageModel
  
  
  def create_tables():
      db.connect()
      db.create_tables((
          UserModel,
          WaifuModel,
          WaifuMessageModel,
      ), True)
-     db.manual_close()
  
  if __name__ == '__main__':
      create_tables()
+     db.manual_close()
  
Fix close connection only when called as script.
## Code Before:
from models.base_model import db
from models.user_model import UserModel
from models.waifu_model import WaifuModel
from models.waifu_message_model import WaifuMessageModel


def create_tables():
    db.connect()
    db.create_tables((
        UserModel,
        WaifuModel,
        WaifuMessageModel,
    ), True)
    db.manual_close()

if __name__ == '__main__':
    create_tables()

## Instruction:
Fix close connection only when called as script.
## Code After:
from models.base_model import db
from models.user_model import UserModel
from models.waifu_model import WaifuModel
from models.waifu_message_model import WaifuMessageModel


def create_tables():
    db.connect()
    db.create_tables((
        UserModel,
        WaifuModel,
        WaifuMessageModel,
    ), True)

if __name__ == '__main__':
    create_tables()
    db.manual_close()
