Skip to content

Instantly share code, notes, and snippets.

@HackToHell HackToHell/export.py
Created Sep 17, 2016

Embed
What would you like to do?
Phabricator Phriction documentation exporter script
import pandas as pd
import os
from sqlalchemy import *
engine = create_engine('mysql://root:test@127.0.0.1/test') #Change me to the phriction database
df=pd.read_sql('select * from phriction_content',engine)
def get(x):
x=x.iloc[0]
try:
os.makedirs('data/'+x['slug'])
except OSError:
print 'k'
with open('data/'+x['slug']+x['title']+'.MD','w') as fp:
fp.write(x['content'])
for name,group in df.groupby('title'):
if len(group) > 1:
x=group[group['version'] == group['version'].max()] #Get only the latest version
get(x)
else:
get(group)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.