#!/usr/bin/python
#-*-coding:utf-8-*-
import json
import os
import sys
import time
import MySQLdb
import base64

host = "localhost"
user = "root"
passwd = "123456"
db = "texas"
charset = "utf8"

def do_insert(cur, filename):
  f = open(filename)
  s = f.read()
  f.close()
  b = base64.b64encode(s)
  sql = "insert into gamedata(`data`) values(%s)"
  param = (b)
  n = cur.execute(sql, (s,))
  conn.commit()
  print "insert sql:", sql
  print "insert result:", n

 
if __name__ == "__main__":

  conn=MySQLdb.connect(host=host,user=user,passwd=passwd,db=db,charset=charset)    
  cursor = conn.cursor()  
  
  do_insert(cursor, sys.argv[1])

