Commit 8fda62fe authored by rico.liu's avatar rico.liu

init

parents
Pipeline #181 canceled with stages
File added
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 11:07:18 2020
@author: rico
"""
import requests
def zgc_api(func,data):
headers = {
'Connection': 'Keep-Alive'
}
key = 'eRo1#ZFHY5N&GEzV'
api = f"http://59.110.219.171:8000/{func}/"
print(api)
data.update({'key':key})
session = requests.session()
result = session.post(api,json=data,headers=headers,timeout=14400).json()
return result
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 7 23:08:30 2020
@author: rico
"""
import pymssql
class MSSQL:
def __init__(self,host,db):
self.host = host
self.db = db
self._conn = self.GetConnect()
if(self._conn):
self._cur = self._conn.cursor()
#连接数据库
def GetConnect(self):
conn = False
if self.host == '123.57.45.119':
user = 'zgcprice'
pwd = 'zgcprice20200708'
elif self.host == '123.56.115.207':
user = 'zgcindex'
pwd = 'jiayou202006'
elif self.host == '10.0.120.131':
user = 'sa'
pwd = '1qaz@WSX'
try:
conn = pymssql.connect(
host=self.host,
user=user,
password=pwd,
database =self.db,
autocommit=True
)
except Exception as err:
print("连接数据库失败, %s" % err)
else:
return conn
#获取连接信息
def GetConnectInfo(self):
print( "连接信息:" )
print( "服务器:%s , 用户名:%s , 数据库:%s " % (self.host,self.user,self.db))
def Close(self):
self._cur.close()
self._conn.close()
'''
ms = MSSQL('123.56.115.207','zdindex')
conn = ms._conn
cursor = ms._cur
cursor.execute(f"select top 10 * from zd_week_price")
cursor.fetchall()
ms.Close()
cursor.close()
conn.close()
'''
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment