I create a database, then I closed and finally delete it with os.remove, but if I try to create the same database with the same line and then insert a new table the compiler says that I cannot operate in a closed database. If I add a db.open() the compiler says that it hasnt an open attribute.
I tried adding the same connect line on another def but I still cannot operate on a "closed" database when its obvious that I deleted it and then created a new database. I use pyqt5 too, thats why I wrote "QMainWindow"
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import uic
import sqlite3
import os
db = sqlite3.connect("prueba.db")
puntero = db.cursor()
#ayuda a este pobre noob que no sabe sqlite3 ni como funciona los argumentos dentro de un def()de python
class Ventana(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        uic.loadUi("base.ui",self)
        self.btn_Tabla.clicked.connect(self.createTabla)
        self.btn_Insertar.clicked.connect(self.createDatos)
        self.btn_Borrar.clicked.connect(self.deleteBase)
        self.btn_Crear.clicked.connect(self.createBase)
    def createBase(self):
        db = sqlite3.connect("prueba.db")
        puntero = db.cursor()
        self.txt_Base.setText("database created")
    def createDatos(self):
        x=1
    def createTabla(self):
        puntero.execute('''
    CREATE TABLE Usuarios(id INTEGER PRIMARY KEY, Nombre TEXT,
                       Telefono TEXT, Correo TEXT unique, Contraseña TEXT)
''')
        db.commit()
        self.txt_Base.setText("tables inserted")
    def deleteBase(self):
        db.close()
        os.remove("prueba.db")
        self.txt_Base.setText("deleted database")       
app = QApplication(sys.argv)
_ventana = Ventana()
_ventana.show()
app.exec_()
