- #!/bin/env python
- #coding:utf-8
- import os,time,stat
- import web
- mydb = web.database(dbn='mysql', db='db', user='user', pw='password',host='localhost')
- sqldb = web.database(dbn='sqlite', db='./db.db' )
- mydb.printing = False
- sqldb.printing = False
- print 'aa'
- for tab in ['t_content', 't_tag', 't_content_tag']:
- print tab ,
- offset = 0
- limit = 1000
- while 1:
- print offset
- data = mydb.select( tab, limit = limit, offset = offset )
- data_list = data.list()
- if not data_list:
- break
- offset = offset + limit
- sqldb.multiple_insert( tab, data_list )
- print 'Done'
- #该片段来自于http://www.codesnippet.cn/detail/140820135144.html
来源: http://www.codesnippet.cn/detail/140820135144.html