Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5530

bjarvis2785 on "Manually changing post status via MySQL command"

$
0
0

Thanks for the reply catacaustic...

This is where it may get a bit trickier.
The script this guy wrote is in Python.

So, the code that takes care of updating the DB is as follows:

debug("Connecting to MySQL databse")
            db = MySQLdb.connect(**sql_cred)
            cur = db.cursor()
            debug("Setting publish status")
            cur.execute(r'UPDATE tm1_posts SET post_status="publish" WHERE ID = %s;' % post_id)
            debug("Setting ZIP URL")
            cur.execute(r'UPDATE tm1_postmeta SET meta_value="%s" WHERE post_id = %s AND meta_key = "file_url";' % (url, post_id))
            debug("Setting zipping_status to processed")
            cur.execute(r'UPDATE tm1_postmeta SET meta_value="processed" WHERE post_id = %s AND meta_key = "zipping_status";' % post_id)
            debug('Reset post_name')
            cur.execute(r'UPDATE tm1_posts SET post_name="test" WHERE ID = %s;' % post_id)
            cur.close()
            db.commit()
            # Save our changes to the database
            debug("Post published")

You can see above in the line cur.execute(r'UPDATE tm1_posts SET post_name="test" WHERE ID = %s;' % post_id) i actually edited this and just tried inserting plain text "test" in to the field instead of trying to insert the text from a variable set earlier in the code.
Even this doesn't update the 'post_name' field.

I then went on and combined the above line with the query that sets the publish status (like in your code example) and ran the script... it set the publish status correctly but didn't update the post_name field...

i'm stumped with this one!


Viewing all articles
Browse latest Browse all 5530

Trending Articles