Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import xmlrpclib
import getpass
import argparse
import datetime
import sys
import sqlite3
def main():
now = str(
parser = argparse.ArgumentParser(prog="timesheet_add", description='Timesheet Filler')
parser.add_argument('-t', '--task', dest='task', metavar='TASK',
help='Task', required=True)
parser.add_argument('-m', '--minutes', dest='minutes', metavar='MINUTES',
help='Minutes', required=True)
args = parser.parse_args()
conn = sqlite3.connect(TIMESHEET_DB)
c = conn.cursor()
c.execute("""CREATE TABLE IF NOT EXISTS activities
(day text, activity text, minutes text, added timestamp)""")
task = str.replace(args.task, '\'', '\'\'')
minutes = args.minutes
c.execute("INSERT INTO activities VALUES ('%s','%s','%s', '%s')" % (
now, task, minutes,
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment