Exemple #1
0
def test_mysql(host, password):
    print("Testing MYSQL")
    try:
        cnx = mysqlconnect(host=host, user='******', password=password)
        cnx.is_connected()
    except Exception as e:
        pass
	def test_server(self,ip=None,port=None,username=None,password=None):
		try:
			_ip = ip or self.ip
			_port = port or self.port 
			_username = username or self.username
			_password = password or self.password
			cnx = mysqlconnect(user=_username, password=_password, host=_ip, port=_port,database='test',connect_timeout=1000)
		except:
			pass
Exemple #3
0
 def connect(self):
     """ouvre l'acces a la base de donnees et lit le schema"""
     if self.connection:
         return
     LOGGER.info("connection %s %s en tant que %s", self.serveur, self.base,
                 self.user)
     # print(
     #     "info:mysql: connection ",
     #     self.serveur,
     #     self.base,
     #     self.user,
     #     "*" * len(self.passwd),
     # )
     port = None
     if " " in self.serveur:
         host, port = self.serveur.split(" ")
     else:
         host = self.serveur
     host = host.split("=")[-1]
     connectparams = {
         "user": self.user,
         "passwd": self.passwd,
         "host": host,
         "db": self.base,
         "charset": "utf8",
     }
     if port:
         port = port.split("=")[-1]
         connectparams["port"] = port
     try:
         connection = mysqlconnect(**connectparams)
         connection.autocommit = True
         self.connection = connection
     except self.DBError as err:
         print(
             "error: mysql: utilisateur ou mot de passe errone sur la base ",
             err)