当我的flask应用程序启动时,它需要通过SQLalchemy向Postgres添加一堆数据。我在找一个好办法。数据是TSV格式的,我已经有了SQLalchemy数据库模型它的架构。现在:
for datafile in datafiles:
with open(datafile,'rb') as file:
# reader = csv.reader(file, delimiter='\t')
reader = csv.DictReader(file, delimiter='\t', fieldnames=[])
OCRs = # somehow efficiently convert to list of dicts...
db.engine.execute(OpenChromatinRegion.__table__.insert(), OCRs)
有没有更好更直接的方法?否则,生成OCRs
的最佳方法是什么?你知道吗
建议的解决方案here似乎很笨拙。你知道吗
相关问题 更多 >
编程相关推荐