以前写的Mysql到Mongodb的数据转换程序,翻了出来,在数据量不大的情况情况完全够用。
# -*- coding: utf-8 -*-
import sys, os
import multiprocessing
import logging
import random
import time, datetime
import MySQLdb
from MySQLdb import cursors
from pymongo import MongoClient
class Config:
tables = ['hs_card', 'hs_hero', 'hs_set', 'hs_skill', 'hs_level', 'hs_pack', 'hs_salesevent']
#tables = ['hs_card', 'hs_hero', 'hs_set', 'hs_skill', 'hs_level']
index = {
'hs_card': ['name'],
}
class Mysql2Mongo(object):
mysql_host = '50.23.4.2'
mysql_port = 3306
mysql_user = "root"
mysql_pass = "stm123"
mysql_db = "ccg_alpha"
mongo_host = '50.23.4.2'
mongo_port = 27017
conn = None
cursor = None
mongo = None
mongodb