A module to fetch data from MySQL db as list or save it as text file
Project description
This package using MySQLdb interface to connect to database. This module will give convenience to fetch data as list (fetch_dbdata_list) and export it to text file (write_dbdata_file), or do all in 1 go using fetch_dbdata_file.
CONTENTS: def fetch_dbdata_file(sql, db_credential, output_filename, mode=”w”, delimiter=”t”) # all in one def fetch_dbdata_list(sql, db_credential, header=True) def write_dbdata_file(data_as_list, output_filename, mode=”w”, header_as_list=[], delimiter=”t”) def write_list_file(list_data, output_filename, mode=”w”)
USAGE: from clioedb import mydb db_credential = { # “user”: “root”, “password”: “password”, “host”: “127.0.0.1”, “db”: “sql_store”, }
sql = “SELECT * FROM sql_store.customers;” output_filename = “output.txt” mydb.fetch_dbdata_file(sql, db_credential, output_filename, “w”, “t”)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.