2018-11-18
- 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
- 同上述情况,在python连接mysql做模糊匹配时,继续报错
con = create_engine('mysql+pymysql://t6:py@zg91S&@222.178.152.79: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