2023年9月13日 星期三

数据库

【库】pymysql

Python3操作MySQL数据库聪明的一休哥哥的博客-CSDN博客python3 操作mysql
https://blog.csdn.net/ylmx5201314/article/details/78052708

Python MySQL数据库的连接以及基本操作_xiaogenggou的博客-CSDN博客
https://blog.csdn.net/xiaogenggou/article/details/105885711

import numpy as np

# 向数据表内插入数据
def test_insert(username, sex, age, table="test"):
    # 编写插入语句,%s表示元素的占位符
    sql_insert = "insert into " + table + " (username,sex,age) values(%s,%s,%s)"
    # 表示从左到右每个占位符所表示的元素的内容
    value = (username, sex, age)
    # 插入数据
    execute(sql_insert, value)

for i in range(10):
    value_username = "test" + str(i + 1)
    a = np.random.permutation(2)
    if a[1] == 1:
        value_sex = "男"
    else:
        value_sex = "女"
    value_age = int(20 + a[0])
    test_insert(value_username, value_sex, value_age)

Paramiko

【问题】installing packages failed pymysql

升级pip解决Install packages failed: Installing packages: error occurred. - 知乎
https://zhuanlan.zhihu.com/p/464506641

Python3报错:ValueError: check_hostname requires server_hostname_海阔天空2018的博客-CSDN博客
https://blog.csdn.net/qq
40024178/article/details/118265274

作者:李世民  创建时间:2023-09-13 02:11
最后编辑:李世民  更新时间:2023-09-13 12:39