Skip to content

Instantly share code, notes, and snippets.

View tonellotto's full-sized avatar

Nicola Tonellotto tonellotto

View GitHub Profile
@tonellotto
tonellotto / gist:5024040587ed73db8f31
Created June 18, 2015 13:46
XML 2 SQL for Stack Overflow
#!/usr/bin/env python
# http://paste.org/8946 "no" 2009
# Updated by Tero Karvinen http://TeroKarvinen.com
import xml.sax.handler
import xml.sax
import sys
class SOHandler(xml.sax.handler.ContentHandler):
def __init__(self):
self.errParse = 0
# Copyright (c) 2013 Georgios Gousios
# MIT-licensed
# Edited to handle two new tables: postLinks and tags that are present in the 2014 dataset
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use stackoverflow;
create table badges (
Id INT NOT NULL PRIMARY KEY,