-1
import the import getpass import mysql.
class Acessdatabase():
UserName = ""
PassWard = ""
DataBase = ""
def LoginDB(self):
self.UserName = input("Username: ")
os.system("cls")
self.PassWard = getpass.getpass("Passward")
os.system("cls")
self.DataBase = input("DataBase:")
self.ConectDB()
def ConectDB(self):
os.system("cls")
conexao = mysql.connector.connect(user = self.Username, password = self.Passward,
host = "localhost", database = self.DataBase )
os.system("pause")
Sistema = AcessDataBase()
Sistema.LoginDB()
how can I store the database name, password and name information within a variable and then use the variable to access the database? I tried to Use Program above but error....
Attention to the indentation of variables
– lazyFox
I believe your problem lies in
host = "localhost"
. Try putting the address directly, something likehost = "127.0.0.1"
– Evilmaax
I tried to do that too....
– Vitor de Jesus
So it works when I do this: (user = "root", password = "", host = "localhost", database = "name..." )
– Vitor de Jesus