工作tip

2018-11-18

  1. python连接mysql 报错:ValueError: unsupported format character ‘Y’ (0x59) at index 70
tmp_sql = "select id, STR_TO_DATE(concat(c_year,'-',c_mon,'-',c_day),'%%Y-%%m-%%d') as bill_time,
proof_no,sub_no,sub_name,chain_no,fnull((select b.chain_name 
from t6.p_dataclean b where  b.old_chain_name  = a.chain_name),a.chain_name) as chain_name,
note,lend_amt,loan_amt,direction,balance,is_not_paid,amount 
from raw.sf_bill a where sub_no in ('2202','2202002') and proof_no is not null "

‘%%Y-%%m-%%d’ , %Y与python的参数%s冲突,所以增加一个%

参考:https://blog.csdn.net/chinacmt/article/details/51883475

####2020-02-07

  1. 同上述情况,在python连接mysql做模糊匹配时,继续报错
con = create_engine('mysql+pymysql://t6:py@[email protected]:4307/student')
sql = "SELECT * FROM schema_meta where schema_parser like '%%Industry%%'"
data = pd.read_sql(sql,con)

在这里插入图片描述
其实,如果要在查询语句中使用%,则应用%%替代

参考:https://blog.csdn.net/weixin_40643642/article/details/103013761

你可能感兴趣的:(工作日志)