Skip to content

Instantly share code, notes, and snippets.

@pabloem
Last active June 22, 2016 14:08
Show Gist options
  • Save pabloem/4e0c93be08e56093b31c0e6ea39c824d to your computer and use it in GitHub Desktop.
Save pabloem/4e0c93be08e56093b31c0e6ea39c824d to your computer and use it in GitHub Desktop.
import subprocess
tables = [
"Dictionary_codi",
"Dictionary_item",
"NFC_hits",
"album",
"apply",
"banner",
"board_comment",
"brand_sendinfo",
"calculate",
"calculate_item",
"cancel_info",
"card_info",
"category",
"codi_history",
"comment",
"contract",
"coordinate",
"dailycodi",
"designer_code",
"em_banlist",
"em_mmt_log_table",
"em_mmt_tran",
"enquire",
"eventBoard",
"faq",
"faq2",
"friend",
"hashtag",
"hashtag_list",
"hits",
"item",
"item_evaluation",
"itembrand",
"itemcategory",
"itemcolor",
"kakao_msg",
"like_user",
"likehistory",
"master_app_info",
"notice",
"order_basket",
"order_error",
"order_history",
"order_info",
"order_item",
"order_log",
"point_history",
"push",
"question",
"ranking",
"recommend",
"recommend_codi",
"recommend_hashtag",
"recommend_log",
"recommend_statistics",
"reservecode",
"sample",
"search",
"server_service",
"storage",
"test_item",
"urlcodemap",
"user",
"user_leave",
"vuser_leave"]
command = ["mysql", "-B", "--host=SECRETESTAISFOAUAG", "--user=SECRETESTAISFOAUAG", "--password=SECRETESTAISFOAUAG", "mapssiDB"]
command = " ".join(command)
print(command)
input = 'select * from '
for table in tables:
with open(table+".csv","w") as f:
p = subprocess.Popen(command, stdout=f,stdin=subprocess.PIPE,shell=True)
p.communicate(input=input+table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment