psycopg2 を使用して float を postgresql の倍精度にバインドしようとしています。
ele = 1.0/3.0
dic = {'name': 'test', 'ele': ele}
sql = '''insert into waypoints (name, elevation) values (%(name)s, %(ele)s)'''
cur = db.cursor()
cur.execute(sql, dic)
db.commit()
sql = """select elevation from waypoints where name = 'test'"""
cur.execute(sql_out)
ele_out = cur.fetchone()[0]
ele_out
0.33333333333300003
ele
0.33333333333333331
明らかに精度は必要ありませんが、値を単純に比較できるようにしたいと考えています。struct モジュールを使用して文字列として保存することもできましたが、もっと良い方法があるはずだと考えました。ありがとう