しょっちゅう忘れることを書いておく。
![]() |
66 |
1159 views
import sqlite3
from contextlib import closing
def create_table(db_path):
with closing(sqlite3.connect(db_path)) as conn:
c = conn.cursor()
sql ="""CREATE TABLE if not exists [ticker] (
[id] INTEGER,
[last] INTEGER,
[bid] INTEGER,
[ask] INTEGER,
[high] INTEGER,
[low] INTEGER,
[volume] INTEGER,
[timestamp] INTEGER,
PRIMARY KEY([id])
);
"""
c.execute(sql)
conn.commit()
import sqlite3
from contextlib import closing
sql = "select min(timestamp) from ticker"
def select(sql):
results = []
rows = c.execute(sql)
for row in rows:
results.append(row)
return results
def insert_rate_pair(c, pair_name, rate, timestamp):
sql = "insert into {}(rate, timestamp) values(?,?)".format(pair_name)
holder = (rate, timestamp)
c.execute(sql, holder)
Page 16 of 69.
すぺぺぺ
本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。
https://www.osumoi-stdio.com/novel/