0
Follow
0
View

python flask imports null sql statements

dldwyq 注册会员
2023-02-28 13:53
< div class = "md_content_show e397 data - v - 3967" = "" >

you're right, is the reason why coding. But when database connect, charset='GB2312', my other sql statements will display, only this one is null, charset is set to utf8, the data from the database will be garbled

cyf8448 注册会员
2023-02-28 13:53

yangyue12306 注册会员
2023-02-28 13:53
< div class = "md_content_show e397 data - v - 3967" = "" >

suggest all use utf8

dz82823 注册会员
2023-02-28 13:53

Yes, I think I've found the problem now. It's a coding problem. When charset='GB2312' in connect, other sql statements will be displayed. Only the sql statement with Chinese characters will have a null value. But when I set the charset to utf-8, getting the database data was garbled

QQ39974867 注册会员
2023-02-28 13:53

Look it up to see what the encoding was when the database was created. Then, when the code is connected, try the same encoding again

edianjun 注册会员
2023-02-28 13:53

default encoding, I do not take Chinese string sql statement, GB2312 can normally display

stvotvcctv 注册会员
2023-02-28 13:53

Obviously, the Chinese in the sql submitted by your program becomes the code \xbd\xa8\xca\xbc\xcf\xd8, This value will not be found in the database, and the return will always be null. The next thing to solve is to solve the problem of sql garble submitted

cuixingwei05 注册会员
2023-02-28 13:53

I looked at the answers and found that
1, the database configuration and links are OK, the database is correct, the table names are correct,
2, the sql statements are OK, The sql copy to navicat executes normally
is that what I understand?

duron571 注册会员
2023-02-28 13:53

print out your sql print in the program, and then take the printed sql, go to the database to see if the result return

kritos 注册会员
2023-02-28 13:53

"select top 10 r.STCD,sum(r.DRP) as DRP_SUM ,b.STNM,b.STLC,b.ADMAUTH from RWDB.dbo.ST_PPTN_R r left join RWDB.dbo.ST_STBPRP_B b on r.STCD=b.STCD where r.TM > = DATEADD(hour, 1, GETDATE()) and b.A DMAUTH = 'jianshi county' group by r.S TCD, b.S TNM, b.S TLC, b.A DMAUTH order by the sum(r.D RP) desc

"

b"select top 10 r.STCD,sum(r.DRP) as DRP_SUM ,b.STNM,b.STLC,b.ADMAUTH from RWDB.dbo.ST_PPTN_R r left join RWDB.dbo.ST_STBPRP_B b on r.STCD=b.STCD where r.TM > = DATEADD(hour,-1,GETDATE()) and b.ADMAUTH ='\xbd\xa8\xca\xbc\xcf\xd8' group by r.STCD,b.STNM,b.STLC,b.ADMAUTH order by sum(r.DRP) desc"

About the Author

Question Info

Publish Time
2023-02-28 13:52
Update Time
2023-02-28 13:52

Related Question

当我使用cron时,Python脚本不运行

在Python中将数据帧转换为嵌套的字典/树

如何在Python列表中添加项目到列表中?(复制)

Python,键盘输入,函数等

在python中查找一行中的小数

使用bs4在python中解析硬币市值的表数据

python质数问题求解

百度地图覆盖物的事件冒泡 domEvent为null

Python.exe-can't open file' c:\\Users\\admin\\Desktop\\Automation\\3.10': [Errno 2]没有这样的文件或目录

关于python的问题,如何解决?