需求是这样的:将两个数据集进行ks检验,算中位数方差标准差等数据,最后输出到数据库中
import psycopg2
import os
import pandas as pd
from scipy.stats import ks_2samp
import numpy as np
from sqlalchemy import create_engine
# 用来操作数据库的类
class GPCommand(object):
# 类的初始化
def __init__(self):
self.hostname = 'ip'
self.username = 'name'
self.password = 'password'
self.database = 'database'
def connectGp(self):
try:
#链接数据库
#读取配置利用connect链接数据库
self.connect = psycopg2.connect( host=self.hostname, user=self.username, password=self.password, dbname=self.database )
#创建一个新的cursor
self.cursor = self.connect.cursor()
print("connect gp successful."+'\n' + '数据库连接成功')
return ('con_successful')
except psycopg2.Error:
error = 'Failed to setup Pos