Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #r "MySql.Data"
- #r "Html2Markdown"
- #r "NPoco"
- //#r "ReverseMarkdown" //this one turned <li> into "-" vs "*"
- //install these libs via scriptcs -install libname
- using NPoco;
- public class Post {
- public double id {get; private set;}
- public string post_content {get; private set;}
- }
- var cxnString = "Server=xxx;Database=xxx;User=xxx;Password=xxx;";
- var database = new Database(cxnString, DatabaseType.MySQL, MySql.Data.MySqlClient.MySqlClientFactory.Instance);
- var query = $@"select
- id,
- post_title,
- post_content,
- post_content_filtered
- from wp_posts as parent
- where post_type = 'post'
- and post_parent = 0
- /*and post_content_filtered = ''*/
- and id in ('{Environment.GetCommandLineArgs()[3]}')
- ;";
- var cxn = new MySql.Data.MySqlClient.MySqlConnection(cxnString);
- var savecmd = cxn.CreateCommand();
- cxn.Open();
- var posts = database.Fetch<Post>(query);
- var converter = new Html2Markdown.Converter();
- foreach(var post in posts) {
- savecmd.CommandText = $"update wp_posts set post_content_filtered = '{converter.Convert(post.post_content).Replace("'", "''")}' where id = {post.id}";
- savecmd.ExecuteNonQuery();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement