CSV是可以直接导入Mysql的,不过有时候条目不对应,CSV数量过多,直接导入就不方便了

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import csv
import pymysql
conn=pymysql.connect(host='xx.xx.xx.xx',port=3306,user='root',password='password',db='weibo',charset='utf8mb4') # 数据库连接信息
cursor=conn.cursor()
for root,dirs,files in os.walk(r"E:\"): #遍历目录
for f in files:
if f.split(".")[-1] == "csv":
user_id=f.split(".")[0]
csv_file=open(os.path.join(root,f),"r",encoding='utf-8')
csv_reader=csv.reader(csv_file)
csv_comment=list(csv_reader)
# print("test")
for t in csv_comment:
if t[0].find("微博id") > -1:
continue
insert="INSERT INTO `weibo` (`id`, `user_id`, `content`, `article_url`, `original_pictures`, `retweet_pictures`, `original`, `video_url`, `publish_place`, `publish_time`, `publish_tool`, `up_num`, `retweet_num`, `comment_num`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}','{10}', '{11}', '{12}', '{13}');".format(t[0],user_id,t[1],t[2],t[3],"NULL","1",t[4],t[5],t[6],t[7],t[8],t[9],t[10]) #对应的插入语句
try:
cursor.execute(insert)
conn.commit()
print("成功")
except:
print("失败")

由于服务器迁移导致自用图床chevereto的数据库丢失(忘记备份是大锅,那段时间忙于考试了),但多处引用了外链不方面自身再次上传,所以根据数据文件补全数据库

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import hashlib
from PIL import Image

def update_info(path,f,root): #查询图片信息,生成SQL语句
image_name=os.path.splitext(f)[0]
image_extension=f.split(".")[-1]
file=open(path,"rb")
image_size=os.path.getsize(path)
im=Image.open(path)
image_width=im.size[0]
image_height=im.size[1]
image_date=path.split("\\")[2]+'-'+path.split("\\")[3]+"-"+path.split("\\")[4]+" 12:00:00"
image_user_id=1
image_uploader_ip="60.211.13.123"
image_md5=hashlib.md5(file.read()).hexdigest()
image_original_filename=f
i_th=os.path.join(root,image_name+".th."+f.split(".")[-1])
i_md=os.path.join(root,image_name+".md."+f.split(".")[-1])
if(os.path.exists(i_th) and os.path.exists(i_md)):
image_chain=7
image_thumb_size=os.path.getsize(i_th)
image_medium_size=os.path.getsize(i_md)
else:
image_chain=5
image_thumb_size=os.path.getsize(i_th)
image_medium_size=0
info="INSERT INTO `chv_images` (`image_id`, `image_name`, `image_extension`, `image_size`, `image_width`, `image_height`, `image_date`, `image_date_gmt`, `image_title`, `image_description`, `image_nsfw`, `image_user_id`, `image_album_id`, `image_uploader_ip`, `image_storage_mode`, `image_storage_id`, `image_md5`, `image_source_md5`, `image_original_filename`, `image_original_exifdata`, `image_views`, `image_category_id`, `image_chain`, `image_thumb_size`, `image_medium_size`, `image_expiration_date_gmt`, `image_likes`, `image_is_animated`) VALUES (NULL, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{5}', '{6}', NULL, '0', '1', NULL, '60.211.13.123', 'datefolder', NULL, '{7}', NULL, '{8}', NULL, '0', NULL, '{9}', '{10}', '{11}', NULL, '0', '0');".format(image_name,image_extension,image_size,image_width,image_height,image_date,image_name[:99],image_md5,f,image_chain,image_thumb_size,image_medium_size)
return info

#遍历图片储存文件夹,所有SQL语句写入文本
total =0
new_info=open("update_info.txt","w")
for root,dirs,files in os.walk(r"D:\images"):#这里写路径
for f in files:
#print(f)
if f.split(".")[-1] not in ["jpg","png"]:
#print(f.split(".")[-1])
continue
if f.split(".")[-2] in ["th","md"]:
#print(f.split(".")[-2])
continue
#print(root)
str_info=update_info(os.path.join(root,f),f,root)
#print(str_info)
new_info.write(str_info)
new_info.write("\n")
total=total+1
print(total)
#print(f)

说明

  • 可以通过pymysql直接写入数据库,我不想开远程数据库访问权限没有使用
  • 直接通过服务端命令行或者PHPmyadmin上传mysql执行即可
  • total的值很有用,本代码默认图床个人使用,图片所有者为id为1的用户。请在数据库chv_users中的user_image_count和chv_stats中total的stat_images加上total的值,否则仪表台的统计数据有误。
  • 修改数据库chv_stats中total的stat_disk_used为images文件夹实际大小,否则仪表台统计数据有误
  • 上述两条不影响使用,只影响观感
  • 另外由于服务器时间和照片时间不一致,容易存在照片信息时间与上传图片的时间文件夹不同,所以图片时间为按照真实时间填写,均设置为上传当天的中午12点,不影响使用。如果使用真实时间戳,导致与文件夹名对不上,后台图片会显示为空。
阅读全文 »

专题二 结构设计与构造

结构的可靠性要求

  1. 功能要求

    安全性、适用性、耐久性

    安全性的功能要求(安全角度):正常施工使用时不发生破坏,偶然事件后保持必要的整体稳定性

    适用性的功能要求(变形角度):正常使用时具有良好的工作性能

    耐久性的功能要求(时间角度):正常维护条件下,在预计的使用年限内满足各项功能要求

  2. 极限状态分类

    • 承载能力极限状态:结构或构件达到最大承载能力(强度)或不适于继续承载的变形(稳定性)。超过后,不满足安全性
    • 正常使用极限状态:结构或构件达到正常使用或耐久性的某项规定的限制(刚性),超过后,不满足实用性和耐久性

    【知识点】施工技术

    1. 预制构件安装:临时固定设施,临时支撑系统具有足够的强度、刚度和整体稳定性。
    2. 模板工程设置的主要原则是实用性、安全性(强度、刚度和稳定性)和经济性

    承载力极限状态的内涵是结构受力,反映的是构件的强度和稳定性,正常使用极限状态的内涵是结构变形,反映的是构件的刚度。

  3. 杆件刚度与梁的位移计算

    • 悬臂梁端位移计算公式\(f=\frac{ql^4}{8EI},I=\frac{bh^3}{12}\)
  4. 混凝土结构的裂缝控制【一般知识点】

    1. 构件不出现拉应力
    2. 构件虽有拉应力,但不超过混凝土的抗拉强度
    3. 允许出现裂缝,但裂缝不超过允许值
  5. 结构设计使用年限

    类别 设计使用年限(年)
    临时性建筑结构 5
    易于替换的结构构件 25
    普通的房屋和构筑物 50
    标志性建筑和特别重要的建筑结构 100

gitalk不知道为什么总是出问题,准备重新投入之前WordPress时代用的Disqus,毕竟最著名的第三方评论插件了

Disqus由于国内不能直接访问,所以不直接采用Disqus官方插件DisqusJS,无法直接访问的网络环境下使用反代的API只能阅读已有评论,可以直接访问是采用完整版插件

Step.1 创建新的站点

image-20210209223201131

内容随便填即可,然后在设置界面找到shortname

阅读全文 »

支持手机直接上传chevereto,并获取外链

支持安卓系统直接分享的方式上传图片

基本上支持大部分常见图床,非开源软件,部分功能需要购买许可。

小白图床

华为应用上也可以搜到

不需要支持chevereto,也可以使用Flutter-PicGo,采用picgo内核,目测可拓展性极大,不过目前ui一般,有能力可以自己修改。

考试说明

  • 单选70题各1分+多选30题各2分
  • 时长180分钟,总分130分,分数线78分

1Z301000 建设工程基本法律知识

1Z301012 法的形式和效力层级

一、法的形式

阅读全文 »

考试科目分析

  • 题型:单选70分+多选30分
  • 总分:130分

专题一:建设工程管理的内涵和任务、建设工程项目管理的目标和任务

1Z201010 建设工程管理的内涵和任务

一、建设工程管理的内涵【掌握】

阅读全文 »

考试分析

  • 百分制
  • 60单选+20多选
  • 工程经济+会计+工程造价

专题一 资金时间价值的计算与应用

知识点 利息的计算

一、时间价值的概念

阅读全文 »

题型及分值

  • 客观题40分+主观题120分

  • 分数:160分

  • 单选20题+多选10题+3题4问+5题2问

专题一 建筑设计与构造

低层或多层民用建筑 <=27m的住宅建筑 <=25m的公共建筑

高层建筑 <100m

阅读全文 »

Step.1

备份、迁移数据,不包括public和node-module文件夹内容

Step.2

新电脑上安装nodejs

Step.3

阅读全文 »
0%