![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
fridayCodeFly
没有难事
展开
-
Python各类数据库连接方法
1.连接mysqlimport pymysql# 1.连接数据库client = pymysql.connect( # 地址 host='127.0.0.1', # 数据库端口 port=3306, # 用户名,要加引号 user='root', # 密码,要加引号 password='2694', # 文件夹 database='db2', # 设置字符编码不能写成了utf-8 charset='ut原创 2021-09-15 16:25:33 · 665 阅读 · 0 评论 -
Python 连接金仓KingbaseES V8遇到的问题
按照网上查到的方法,将金仓的驱动模块放到把驱动放入python库搜索路径,按照查到的方法,提供了3种方法:1、当前目录2、如果不在当前目录,Python 则搜索在 shell 变量 PYTHONPATH 下的每个目录。3、如果都找不到,Python会察看默认路径。UNIX下,默认路径一般为/usr/local/lib/python/。第1个好理解,就是项目当前所在的目录。把ksycopg2文件夹直接复制到项目的目录下面即可。第2个,则是环境变量PYTHONPATH所指向的目录,如果没有可以添原创 2021-09-13 17:30:34 · 1740 阅读 · 4 评论 -
Python 数据库字段类型对应代码
ft = MySQLdb.constants.FIELD_TYPE d = {getattr(ft, k): k for k in dir(ft) if not k.startswith('_')} d {0: 'DECIMAL', 1: 'TINY', 2: 'SHORT', 3: 'LONG', 4: 'FLOAT', 5: 'DOUBLE', 6: 'NULL', 7: 'TIMESTAMP', 8: 'LONGLONG', 9: 'INT24', 10: 'DATE..原创 2021-09-12 01:04:08 · 626 阅读 · 0 评论 -
python判断数组里面是否有某个值或没有某个值
应用print 3 in [1, 2, 3] # membership (1 means trueinventory = ["sword", "armor", "shield", "healing potion"]if "healing potion" in inventory: print "You will live to fight another day." # 假如某个表有6个字段 # exclude是要排除的字段的数组,其形如["field1","field2","fiel原创 2021-09-07 14:51:22 · 12901 阅读 · 0 评论 -
python多数相加函数
def sums(*nums): return sum(nums)beer = 2 * 6milk = 1 * 15bread = 3 * 10total = sums(beer,milk,bread)print(total)原创 2021-09-06 17:27:41 · 2132 阅读 · 0 评论