Playing With DasBlog
Every once in a while you see a couple of messages from the guys that use a Blog with a DB backend post some wonderful statistics about their Blog. I couldn't be happier with dasBlog (can you say zero headache in over two years of using it?), but I really like the statistics abilities. Well, I like to think of myself as a developer, and as such, I can solve such problems. Put this together with the SQL stuff I've been doing lately, and that dasBlog has Web Services functionality, and the solution is obvious, isn't it?
I'm going to explain how I did it now, and then post the stats in the next post (along with some nice graphs, I hope.) The first thing that I did was to take my previous post about dasBlog's Web Services, and took it for a spin, here are the results:
import System
import System.Data
import System.Data.SqlClient
import CookComputing.XmlRpc
import newtelligence.DasBlog.Runtime.Proxies
user = "Ayende Rahien"
password = "Ayende@ayende.com"
start = DateTime.Now
log = IO.File.CreateText("log.txt")
dasBlog = BloggerAPIClientProxy()
dasBlog.Url = "http://www.ayende.com/Blog/blogger.aspx"
posts = dasBlog.metaweblog_getRecentPosts("",user, password, 1500)
print "Got ${posts.Length} posts from server"
using con = SqlConnection("""Data Source=.;AttachDbFilename=F:.mdf;Integrated Security=True;User Instance=True"""):
con.Open()
using command = con.CreateCommand():
command.CommandText = "INSERT INTO BlogStats(Time, Title) VALUES(@time, @title)"
time = command.Parameters.Add("time", SqlDbType.DateTime)
title = command.Parameters.Add("title", SqlDbType.NChar)
for post in posts:
try:
time.Value = post.dateCreated
title.Value = post.title
command.ExecuteNonQuery()
except e:
print "Error updated post: ${post.title}"
print e.Message
log.WriteLine(e.ToString())
log.WriteLine("--- --- ---")
print "Took ${DateTime.Now - start}"
Comments
Comment preview