mysql decimal数据类型转换的实现
16lz
2021-12-13
最近在工作遇到数据库中存的数据类型是: decimal(14,4)
遇到的问题是:
当我使用python 读取到内存中时,总是带着 decimal字符, 再写入其它mysql表中时,数据类型为int型,导致数据入库不成功.
import pymysql# 创建数据库连接con = pymysql.connect()sql = '''selectcreated_timefrom schma.tableLIMIT 10'''try: cur = con.cursor(cursor=pymysql.cursors.DictCursor) cur.execute(sql)except Exception as e: print(e)else: data = cur.fetchall()finally: cur.close() con.close()for d in data: created_time = d.get('created_time') print(created_time)
selectcast(created_time as signed) AS created_time from schma.table
更多相关文章
- MySQL系列多表连接查询92及99语法示例详解教程
- Linux下MYSQL 5.7 找回root密码的问题(亲测可用)
- MySQL 什么时候使用INNER JOIN 或 LEFT JOIN
- android从服务器下载文件(php+apache+win7+MySql)
- 【有图】android通过jdbc连接mysql(附文件)
- Android开发 数据库操作
- android中的数据库操作
- android 通过php 连接 mysql
- android通过php连接mysql数据库!!!!