篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 脚本para merge de files sql相关的知识,希望对你有一定的参考价值。
# coding=utf-8
#########################################################
# Script para pegar varios arquivos sql em um diretorio
# e mesclar todos em um unico arquivo.
# by: Anderson Firmino (coderpy) <anderson.araujoprog@gmail.com>
# by: Gustavo Rodrigo (hpix) <rodrigogustavo_@hotmail.com>
#########################################################
import os
def procedimento(path):
final_file = ""
for fn in os.listdir(path):
fn = path + fn
with open(fn, 'r') as f:
final_file += f.read()
with open('final.sql', 'w') as f:
f.write(final_file)
if __name__ == '__main__':
directory = os.path.dirname(os.path.abspath(__file__))
directory += "/directory/"
procedimento(directory)
以上是关于python 脚本para merge de files sql的主要内容,如果未能解决你的问题,请参考以下文章