Commit 8580eaf6 by lzzzzl

提交db文件

parent 51f9623d
Showing with 348 additions and 1 deletions
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
out out
log log
gen gen
/config/db_config.py gen
# Python files # Python files
Test.py Test.py
# _*_ coding:utf-8 _*_
import sys
import pymysql
from elasticsearch import Elasticsearch
zy_conn = {
'host': '172.18.137.33',
'port': 3306,
'user': 'LxDDUsedRead',
'password': '0o9u0U2oixoYmosflmxXtZmyt',
'db': 'liexin_data',
'charset': 'utf8'
}
local_conn = {
'host': 'localhost',
'port': 3306,
'user': 'root',
'password': 'qaz',
'db': 'bigdata',
'charset': 'utf8'
}
# SKU
# db-user :LxiCSpuR
# db-pwd :Mysx3Tyzlo00oxlmllyR
# db-host : spu-slave.ichunt.db
online_sku = {
'host': 'spu-slave.ichunt.db',
'port': 3306,
'user': 'LxiCSpuR',
'password': 'Mysx3Tyzlo00oxlmllyR',
}
local_sku_conn = {
'host': '192.168.1.235',
'port': 3306,
'user': 'spu',
'password': 'spu',
'db': 'liexin_spu',
'charset': 'utf8'
}
local_test = {
'host': 'localhost',
'port': 3306,
'user': 'root',
'password': 'qaz',
'db': 'test',
'charset': 'utf8'
}
local_mapping_conn = {
'host': 'localhost',
'port': 3306,
'user': 'root',
'password': 'qaz',
'db': 'mapping',
'charset': 'utf8'
}
dashboard_conn = {
'host': 'localhost',
'port': 3306,
'user': 'dashboard',
'password': 'ichunt5Dashboard@',
'db': 'dashboard',
'charset': 'utf8'
}
order_conn = {
'host': '172.18.137.22',
'port': 3306,
'user': 'huntdbslave',
'password': 'mLssy2@@!!@$#yy',
'db': 'hunt2016',
'charset': 'utf8'
}
learning_conn = {
'host': 'localhost',
'port': 3306,
'user': 'lEaUx',
'password': 'Xp#psOlT@!@#lfs^%wl',
'db': 'learning_data',
'charset': 'utf8'
}
bigdata_conn = {
'host': '192.168.2.232',
'port': 3306,
'user': 'bigdata',
'password': 'bigdata2019',
'db': 'digikey',
'charset': 'utf8'
}
new_bigdata_conn = {
'host': '192.168.1.234',
'port': 3306,
'user': 'digikey',
'password': 'digikey#zsyM',
'db': 'digikey',
'charset': 'utf8'
}
online_bigdata_conn = {
'host': '172.18.137.37',
'port': 3306,
'user': 'bigdata',
'password': 'bdYm2yy2mmyzlmlly',
'db': 'digikey',
'charset': 'utf8'
}
class_conn = {
'host': '192.168.2.250',
'port': 3306,
'user': 'root',
'password': 'root',
'db': 'liexin_pool_class',
'charset': 'utf8'
}
class_conn_online = {
'host': 'spu-master.ichunt.db',
'port': 3306,
'user': 'LxiUndata',
'password': 'uzsx3Tyzlo00oxlmqlt',
'db': 'liexin_union_data',
'charset': 'utf8'
}
# db-user :LxiCSpuR
# db-pwd :Mysx3Tyzlo00oxlmllyR
# db-host : spu-slave.ichunt.db
spu_conn = {
'host': '192.168.1.235',
'port': 3306,
'user': 'spu',
'password': 'spu',
'db': 'liexin_spu',
'charset': 'utf8'
}
spu_conn_online = {
'host': 'spu-master.ichunt.db',
'port': 3306,
'user': 'LxiCSpu',
'password': 'Mysx3Tyzlo00oxlmlly',
'db': 'liexin_spu',
'charset': 'utf8'
}
local_learning_conn = {
'host': '192.168.1.235',
'port': 3306,
'user': 'learning_data',
'password': 'learning_data#zsyM',
'db': 'learning_data',
'charset': 'utf8'
}
local_spu = {
'host': '192.168.1.235',
'port': 3306,
'user': 'spu',
'password': 'spu',
'charset': 'utf8'
}
local_es = [{
'host': '192.168.2.232',
'port': 9200
}]
online_es = [{
"host": "172.18.137.30",
"port": 9211
}]
def get_env():
if sys.platform in ('darwin', 'win32'):
return 'test'
else:
return 'produce'
class DBConn:
@staticmethod
def local_conn():
return pymysql.connect(local_conn['host'],
local_conn['user'],
local_conn['password'],
local_conn['db'],
charset=local_conn['charset'])
@staticmethod
def local_test():
return pymysql.connect(local_test['host'],
local_test['user'],
local_test['password'],
local_test['db'],
charset=local_test['charset'])
@staticmethod
def local_mapping_conn():
return pymysql.connect(local_mapping_conn['host'],
local_mapping_conn['user'],
local_mapping_conn['password'],
local_mapping_conn['db'],
charset=local_mapping_conn['charset'])
@staticmethod
def zy_conn():
return pymysql.connect(zy_conn['host'],
zy_conn['user'],
zy_conn['password'],
zy_conn['db'],
charset=zy_conn['charset'])
@staticmethod
def order_conn():
return pymysql.connect(order_conn['host'],
order_conn['user'],
order_conn['password'],
order_conn['db'],
charset=order_conn['charset'])
@staticmethod
def dashboard_conn():
return pymysql.connect(dashboard_conn['host'],
dashboard_conn['user'],
dashboard_conn['password'],
dashboard_conn['db'],
charset=dashboard_conn['charset'])
@staticmethod
def learning_conn():
return pymysql.connect(learning_conn['host'],
learning_conn['user'],
learning_conn['password'],
learning_conn['db'],
charset=learning_conn['charset'])
@staticmethod
def new_bigdata_conn():
return pymysql.connect(new_bigdata_conn['host'],
new_bigdata_conn['user'],
new_bigdata_conn['password'],
new_bigdata_conn['db'],
charset=new_bigdata_conn['charset'])
@staticmethod
def local_es():
return Elasticsearch(local_es)
@staticmethod
def online_es():
return Elasticsearch(online_es)
@staticmethod
def es():
if get_env() == 'test':
return Elasticsearch(local_es)
else:
return Elasticsearch(online_es)
@staticmethod
def db_learning():
if get_env() == 'test':
return pymysql.connect(local_learning_conn['host'],
local_learning_conn['user'],
local_learning_conn['password'],
local_learning_conn['db'],
charset=local_learning_conn['charset'])
else:
return pymysql.connect(learning_conn['host'],
learning_conn['user'],
learning_conn['password'],
learning_conn['db'],
charset=learning_conn['charset'])
@staticmethod
def db_dashboard():
if get_env() == 'test':
return pymysql.connect(local_mapping_conn['host'],
local_mapping_conn['user'],
local_mapping_conn['password'],
local_mapping_conn['db'],
charset=local_mapping_conn['charset'])
else:
return pymysql.connect(dashboard_conn['host'],
dashboard_conn['user'],
dashboard_conn['password'],
dashboard_conn['db'],
charset=dashboard_conn['charset'])
@staticmethod
def db_bigdata():
if get_env() == 'test':
return pymysql.connect(bigdata_conn['host'],
bigdata_conn['user'],
bigdata_conn['password'],
bigdata_conn['db'],
charset=bigdata_conn['charset'])
else:
return pymysql.connect(online_bigdata_conn['host'],
online_bigdata_conn['user'],
online_bigdata_conn['password'],
online_bigdata_conn['db'],
charset=online_bigdata_conn['charset'])
@staticmethod
def db_class():
if get_env() == 'test':
return pymysql.connect(class_conn['host'],
class_conn['user'],
class_conn['password'],
class_conn['db'],
charset=class_conn['charset'])
else:
return pymysql.connect(class_conn_online['host'],
class_conn_online['user'],
class_conn_online['password'],
class_conn_online['db'],
charset=class_conn_online['charset'])
@staticmethod
def db_spu():
if get_env() == 'test':
return pymysql.connect(spu_conn['host'],
spu_conn['user'],
spu_conn['password'],
spu_conn['db'],
charset=spu_conn['charset'])
else:
return pymysql.connect(spu_conn_online['host'],
spu_conn_online['user'],
spu_conn_online['password'],
spu_conn_online['db'],
charset=spu_conn_online['charset'])
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 sign in to comment