JSON型を使えばいけそうな気がします https://qiita.com/kumazo/items/483f47360f8b61a9fbb9
しかし、そもそもitems
みたいなテーブルを用意してname
とamount
みたいなカラムで管理してあげた方が良い気がします
0Like
JSON型を使えばいけそうな気がします https://qiita.com/kumazo/items/483f47360f8b61a9fbb9
しかし、そもそもitems
みたいなテーブルを用意してname
とamount
みたいなカラムで管理してあげた方が良い気がします
再起動でデータが失われるのであれば、pythonからCSVを読み込んでpostgresqlに入れるのはいかがでしょうか。csvならexcelみたいなので編集ができます。
import psycopg2 #import the Postgres library
#connect to the database
conn = psycopg2.connect(host='localhost',
dbname='mytestdb',
user='postgres',
password='')
#create a cursor object
#cursor object is used to interact with the database
cur = conn.cursor()
#create table with same headers as csv file
cur.execute('''create table test(name char(50), age char(50), height char(50));''')
#open the csv file using python standard file I/O
#copy file into the table just created
f = open('file.csv','r')
cursor.copy_from(f, 'test', sep=',')
f.close()