sql - 这段代码如何pythonic,数据库查询
PHPz
PHPz 2017-04-18 09:34:51
0
1
265
PHPz
PHPz

学习是最好的投资!

Antworte allen(1)
小葫芦
  • 可以尝试不要自己拼SQL语句,利用系统库自带的函数,例如

results = cur.select(table = 'articles', columns = ['id','link','is_keywords_avaliable'], where = correct_parms) # 具体的参数我也记得不清楚,可以自己查查看。
  • 利用格式化字符串可以方便地替换参数。

sql = "select {columns} from {table} {is_where} {condition}".format(columns = 'id, link, is_keywords_available', table = 'articles', is_where = "where", condition = ".....")
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage