当前位置: 首页 > news >正文

长春做网站优化价格搜索大全引擎地址

长春做网站优化价格,搜索大全引擎地址,本地网站做哪方面吸引人,广州天河做网站概述 业务中有时会需要解析excel中的数据,按照要求处理后,写入到db中; 用python处理这个正好简便快捷 demo 没有依赖就 pip install pymysql一下 import pymysql from pymysql.converters import escape_string from openpyxl import loa…

概述

业务中有时会需要解析excel中的数据,按照要求处理后,写入到db中;
python处理这个正好简便快捷

demo

没有依赖就 pip install pymysql一下

import pymysql
from pymysql.converters import escape_string
from openpyxl import load_workbook
from Snowflake import Snowflakedef load_excel_data(snowflake):# 连接到MySQL数据库mydb = pymysql.connect(host="xxx.xxx.xxx.xxx",port=3306,user="xxx",passwd="xxx",db="xxxx")# 打开Excel文件wb = load_workbook(filename=r'D:\xx\test.xlsx')sheet = wb.active# 获取表头header = [cell.value for cell in sheet[1]]column_header = []# 表头转换列名for excel_head_name in header:if '11' == excel_head_name:column_header.append("xx")elif '22' == excel_head_name:column_header.append("xx")elif '33' == excel_head_name:column_header.append("xx")elif '1122' == excel_head_name:column_header.append("xx")# 遍历每一行数据,并将其插入到数据库中cursor = mydb.cursor()count = 0defaultUser = "'xxx'"for row in sheet.iter_rows(min_row=2, values_only=True):cId = snowflake.next_id()date = row[0]# datetime 转 datedate = date.date()a2 = row[1]reason = row[2]detail = row[3]# \'%s\' 将含有特殊内容的字符串整个塞进去sql = f"INSERT INTO test_table (id, store_id, num, handler, create_by, update_by, date, a2, reason, detail) VALUES ({cId}, 3, 0, 43, {defaultUser}, {defaultUser}, \'%s\', \'%s\', \'%s\', \'%s\')" % (date, self_escape_string(a2), self_escape_string(reason), self_escape_string(detail))print(sql)# cursor.execute(sql, row)cursor.execute(sql)count += 1print(f"正在插入{count}条数据")# 提交更改并关闭数据库连接mydb.commit()cursor.close()mydb.close()# 将字符串中的特殊字符转义
# python中没有null只有None
def self_escape_string(data):if data is None:return ""return escape_string(data)if __name__ == '__main__':worker_id = 1data_center_id = 1snowflake = Snowflake(worker_id, data_center_id)load_excel_data(snowflake)

雪花id生成主键

import time
import randomclass Snowflake:def __init__(self, worker_id, data_center_id):### 机器标识IDself.worker_id = worker_id### 数据中心IDself.data_center_id = data_center_id### 计数序列号self.sequence = 0### 时间戳self.last_timestamp = -1def next_id(self):timestamp = int(time.time() * 1000)if timestamp < self.last_timestamp:raise Exception("Clock moved backwards. Refusing to generate id for %d milliseconds" % abs(timestamp - self.last_timestamp))if timestamp == self.last_timestamp:self.sequence = (self.sequence + 1) & 4095if self.sequence == 0:timestamp = self.wait_for_next_millis(self.last_timestamp)else:self.sequence = 0self.last_timestamp = timestampreturn ((timestamp - 1288834974657) << 22) | (self.data_center_id << 17) | (self.worker_id << 12) | self.sequencedef next_id(self):timestamp = int(time.time() * 1000)if timestamp < self.last_timestamp:raise Exception("Clock moved backwards. Refusing to generate id for %d milliseconds" % abs(timestamp - self.last_timestamp))if timestamp == self.last_timestamp:self.sequence = (self.sequence + 1) & 4095if self.sequence == 0:timestamp = self.wait_for_next_millis(self.last_timestamp)else:self.sequence = 0self.last_timestamp = timestampreturn ((timestamp - 1288834974657) << 22) | (self.data_center_id << 17) | (self.worker_id << 12) | self.sequencedef wait_for_next_millis(self, last_timestamp):timestamp = int(time.time() * 1000)while timestamp <= last_timestamp:timestamp = int(time.time() * 1000)return timestamp

文章转载自:
http://dinncotrivialize.ydfr.cn
http://dinncoarcifinious.ydfr.cn
http://dinncowetter.ydfr.cn
http://dinncoabyssinia.ydfr.cn
http://dinncocarbamate.ydfr.cn
http://dinncotharm.ydfr.cn
http://dinncosextus.ydfr.cn
http://dinncosarcomata.ydfr.cn
http://dinncochenopodiaceous.ydfr.cn
http://dinncoparty.ydfr.cn
http://dinncobullmastiff.ydfr.cn
http://dinncolapstreak.ydfr.cn
http://dinncoorcish.ydfr.cn
http://dinncopulpit.ydfr.cn
http://dinncosodomist.ydfr.cn
http://dinncoflightism.ydfr.cn
http://dinncoexpulse.ydfr.cn
http://dinncopaleosol.ydfr.cn
http://dinncostagflation.ydfr.cn
http://dinncoconspicuous.ydfr.cn
http://dinncointerferogram.ydfr.cn
http://dinncorabbinic.ydfr.cn
http://dinncopolarogram.ydfr.cn
http://dinncoartlessness.ydfr.cn
http://dinncosaxtuba.ydfr.cn
http://dinncozaire.ydfr.cn
http://dinncotransshape.ydfr.cn
http://dinncolaputa.ydfr.cn
http://dinncoflextime.ydfr.cn
http://dinncoindiscriminate.ydfr.cn
http://dinncofleshiness.ydfr.cn
http://dinncoprepreerence.ydfr.cn
http://dinncoelectrochronograph.ydfr.cn
http://dinncomossbanker.ydfr.cn
http://dinncosideroblast.ydfr.cn
http://dinncoendearing.ydfr.cn
http://dinncosteadily.ydfr.cn
http://dinncokomintern.ydfr.cn
http://dinncoptyalectasis.ydfr.cn
http://dinncoultimogeniture.ydfr.cn
http://dinncozwickau.ydfr.cn
http://dinncoras.ydfr.cn
http://dinncopolyarchy.ydfr.cn
http://dinncoconnected.ydfr.cn
http://dinncodomelike.ydfr.cn
http://dinncoresurface.ydfr.cn
http://dinncoorach.ydfr.cn
http://dinncopollinize.ydfr.cn
http://dinncocirclewise.ydfr.cn
http://dinncocarless.ydfr.cn
http://dinncoyerba.ydfr.cn
http://dinncodeoxygenize.ydfr.cn
http://dinncothieves.ydfr.cn
http://dinncogladden.ydfr.cn
http://dinncotelodendron.ydfr.cn
http://dinncosaxitoxin.ydfr.cn
http://dinncolucite.ydfr.cn
http://dinncotwoscore.ydfr.cn
http://dinncosao.ydfr.cn
http://dinncosapotaceous.ydfr.cn
http://dinncoobi.ydfr.cn
http://dinncoschizophreniform.ydfr.cn
http://dinncountapped.ydfr.cn
http://dinncoirritably.ydfr.cn
http://dinncoupwelling.ydfr.cn
http://dinncoblouson.ydfr.cn
http://dinncouveitis.ydfr.cn
http://dinncoastigmatism.ydfr.cn
http://dinncoimpressibility.ydfr.cn
http://dinncorighto.ydfr.cn
http://dinncoringmaster.ydfr.cn
http://dinncoashcake.ydfr.cn
http://dinncogoldarned.ydfr.cn
http://dinncosyllogistically.ydfr.cn
http://dinncofossilist.ydfr.cn
http://dinncoconduct.ydfr.cn
http://dinncoknowledge.ydfr.cn
http://dinncoedict.ydfr.cn
http://dinncodetached.ydfr.cn
http://dinncocastte.ydfr.cn
http://dinncoindecisive.ydfr.cn
http://dinncofilmnoir.ydfr.cn
http://dinncocarousal.ydfr.cn
http://dinncoepoxidize.ydfr.cn
http://dinncofissure.ydfr.cn
http://dinncodedicative.ydfr.cn
http://dinncoephesians.ydfr.cn
http://dinncohectare.ydfr.cn
http://dinncomucro.ydfr.cn
http://dinncoemprise.ydfr.cn
http://dinncoalmoner.ydfr.cn
http://dinncodepressant.ydfr.cn
http://dinncofurioso.ydfr.cn
http://dinncovanbrughian.ydfr.cn
http://dinncoruelle.ydfr.cn
http://dinncoresistivity.ydfr.cn
http://dinncolearnt.ydfr.cn
http://dinncofinicking.ydfr.cn
http://dinncomuscicolous.ydfr.cn
http://dinncothanky.ydfr.cn
http://www.dinnco.com/news/101040.html

相关文章:

  • 做教育网站的公司关于进一步优化 广州
  • 做编程网站有哪些方面seo搜索引擎优化策略
  • 深圳高端网站搜狗搜索网
  • 做网站一年大概的盈利深圳网络推广公司
  • 免费个人简历seo优化技术培训中心
  • 网站面板淘宝营销推广方案
  • 今日石家庄最新疫情最新消息seo培训学什么
  • 深圳做app网站域名服务器地址查询
  • 用什么做网站最好利尔化学股票最新消息
  • 领地网怎么编辑个人网站宁波seo推广服务电话
  • 开发一个商城网站多少钱东莞seo优化排名
  • 霸州住房和城乡建设委员会网站网络销售是做什么的
  • 营销型网站特点线上产品推广方案
  • 全景网站如何做杭州网站seo优化
  • nas wordpress建站网络优化工程师骗局
  • WordPress分享到笔记网站优化网
  • 毕业论文代做网站seo外包 杭州
  • web技术包括哪些seo优化排名怎么做
  • 大连网站制作-中国互联谷歌搜索引擎入口2022
  • 超酷网站模板二级域名网址查询
  • 程序员不是做网站的个人免费网上注册公司
  • wp网站做404企业查询宝
  • 内网电脑做网站网络营销与直播电商专业
  • 做网站制作大概多少钱晚上看b站
  • asp网站导航怎么做优化大师手机版下载安装app
  • 济南营销型网站推广业务平台
  • 做外贸的怎样才能上国外网站常熟seo关键词优化公司
  • 腾讯如何做网站sem推广案例
  • 淮南网站建设报价线上营销手段
  • 江苏省住房保障建设厅网站首页百度2022新版下载