Neroi

执行原生SQL:

1         from django.db import connection, connections
2         cursor = connection.cursor()
3         cursor.execute(
4              """select * from tb where nid=%s""",[user.nid, ])
5         result = cursor.fetchall()
原生SQL

 赋值放在第二个参数,防止SQL注入

对于时间进行格式化:

  1. SQLite时间戳---->日期格式:
1 strftime("%Y-%m-01",ctime)

  转换回时间戳:

strftime(\'%s\',strftime("%Y-%m-01",ctime))

  2.MySQ时间戳---->日期格式:

1 date_format(NOW(),\'%Y-%m-%d %H:%i:%s\')

MYSQL日期--->时间戳:

UNIX_TIMESTAMP(\'2006-11-04 12:23:00\');

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

JS时间戳+new Date()

JS日期格式new Date()
 

 

分类:

技术点:

相关文章:

  • 2021-10-12
  • 2021-10-08
  • 2022-01-20
  • 2022-02-04
  • 2021-10-10
猜你喜欢
  • 2022-01-31
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
相关资源
相似解决方案