Example #1
0
 def CONN_MYSQL_d(self):
     return my_connect(host=conf.get("MYSQL_D_IP"),
                       user=conf.get("MYSQL_D_USER"),
                       password=conf.get("MYSQL_D_PASS"),
                       port=conf.get("MYSQL_D_PORT"),
                       database=conf.get("MYSQL_D_DB"),
                       charset=conf.get("MYSQL_D_CHARSET"),
                       cursorclass=cursors.SSDictCursor)
Example #2
0
 def CONN_MYSQL_h(self):
     return my_connect(host=conf.get("MYSQL_H_IP"),
                       user=conf.get("MYSQL_H_USER"),
                       password=conf.get("MYSQL_H_PASS"),
                       port=conf.get("MYSQL_H_PORT"),
                       database=conf.get("MYSQL_H_DB"),
                       charset=conf.get("mysql_h_charset"),
                       cursorclass=cursors.SSDictCursor)
Example #3
0
    def __init__(
        self,
        table,
        db_type,
        db_name,
        db_user=None,
        db_password=None,
        db_host=None,
        db_port=None,
    ):
        super().__init__()

        if re.match(r"^[\w_]+$", table):
            self.table = table
        else:
            raise ValueError("Invalid database table name")

        self.db_type = db_type
        if db_type == "postgres":
            kwargs = {
                "dbname": db_name,
                "host": db_host,
                "password": db_password,
                "port": db_port or 5432,
                "user": db_user,
            }
            self.connection = pg_connect(
                **{k: v
                   for k, v in kwargs.items() if v})
        elif db_type in ("mariadb", "mysql"):
            kwargs = {
                "database": db_name,
                "host": db_host,
                "password": db_password,
                "port": db_port or 3306,
                "user": db_user,
            }
            self.connection = my_connect(
                **{k: v
                   for k, v in kwargs.items() if v})
        elif db_type == "influxdb":
            kwargs = {
                "database": db_name,
                "host": db_host,
                "password": db_password,
                "port": db_port or 8086,
                "username": db_user,
            }
            self.connection = influx_connect(
                **{k: v
                   for k, v in kwargs.items() if v})
        else:
            raise NotImplementedError()
Example #4
0
 def CONN_MYSQL_duckchat(self):
     return my_connect(host='',user='',password='',port=3306, database='',charset='utf8mb4', cursorclass=cursors.SSDictCursor)
Example #5
0
 def CONN_MYSQL_hawaii(self):
     return my_connect(host='',user='******',password='',port=3306, database='',charset='utf8mb4')