WordPress permalink from the database?

Instead of getting stuff from the database, access the site via its feed.

http://example.com/?p=POST-ID&feed=rss2 will give you information about the post, including the permalink (in the <link> tag).