This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
Control_DB_date
=======

适合场景是 数据库因为量大,根据日期切分成不同的库,该模块会根据你提供的时间段,调度到不同的数据库,可扩展不同的IP地址调度......

当时是为了实现ES库的中心调度,加了层tornado的api,为不同client提供不同的策略。实现的方法还是有些粗糙,有时间在进一步的改进一下... ...

.. image:: http://img3.douban.com/view/biz/raw/public/f477075ba610e94.jpg
:height: 240px
:width: 300 px

Install from Pypi
-----------------

pip install Control_DB_date


Basic Example
-------------
#coding:utf-8
from datetime import datetime
from datetime import timedelta
import time

class Match_db_date(object):
"""
Match = Match_db_date()
import json
print json.dumps(Match.to_match('2014-01-11','2014-08-22'))
"""
def getMonthDays(self, year, month ):
day = 31
while day:
try:
time.strptime( '%s-%s-%d'%( year, month, day ), '%Y-%m-%d' )
return day
except:
day -= 1

def fit_date_format(self,year,month):
if month<10:
str_db = "buzz_v1_%s0%s"%(year,month)
else:
str_db = "buzz_v1_%s%s"%(year,month)
return str_db

def to_match(self,start,end):
dc = {}
opt_start_time = datetime.strptime(start,"%Y-%m-%d")
opt_end_time = datetime.strptime(end,"%Y-%m-%d")
count_month = opt_end_time.month - opt_start_time.month
if count_month == 0:
"""buzz_v1_201502"""
str_db = "buzz_v1_%s"%opt_start_time.strftime('%Y%m')
dc[str_db] = [start,end]
return dc

for i in range(0,count_month+1):
if i == 0:
year = opt_start_time.year
month = opt_start_time.month
dc[self.fit_date_format(year,month)] = [start,"%s-%s-%s"%(year,month,self.getMonthDays(year,month))]

elif i == count_month:
year = opt_end_time.year
month = opt_end_time.month
day = opt_end_time.month
dc[self.fit_date_format(year,month)] = ["%s-%s-01"%(year,month),end]

else:
year = opt_start_time.year
month = opt_start_time.month+i
if month<=12:
dc[self.fit_date_format(year,month)] = ["%s-%s-01"%(year,month),"%s-%s-%s"%(year,month,self.getMonthDays(year,month) )]
else:
year = month / 12 + year
month = month % 12
dc[self.fit_date_format(year,month)] = ["%s-%s-01"%(year,month),"%s-%s-%s"%(year,month,getMonthDays(year,month))]

return dc


How to use it
-------------
from Control_DB_date import *
Match = Match_db_date()
Match.to_match('2014-05-11,'2014-09-11')
Release History

Release History

3.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.5.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Control_DB_date-3.0.0.tar.gz (3.0 kB) Copy SHA256 Checksum SHA256 Source Aug 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting