#!/usr/bin/env python3 import pyinputplus import settings import os try: conn = pymysql.connect( user=str(settings.user), password=str(settings.password), host=str(settings.host), port=settings.port, database=str(settings.database) ) except Exception as e: # print error message when Exception occurs print(f"Error connecting to MariaDB Platform: {e}") sys.exit(1) cur = conn.cursor() if os.path.exists('/home/uzer/PycharmProjects/pythonProject/data.txt'): print("File exists") else: username = pyinputplus.inputEmail('Username (must be existing email): ', limit=3) cur.execute('SELECT * FROM database WHERE userID = "' + str(username) + '"') bas = cur.fetchone() print(str(bas[5]))
Но такая ошибка появляется.
Traceback (most recent call last): File "./script.py", line , in <module> print(str(bas[5])) TypeError: 'NoneType' object is not subscriptable