Skip to content

Instantly share code, notes, and snippets.

@q0rban
Created July 8, 2013 06:08
Show Gist options
  • Select an option

  • Save q0rban/5946539 to your computer and use it in GitHub Desktop.

Select an option

Save q0rban/5946539 to your computer and use it in GitHub Desktop.
My first python script!
#!/usr/bin/env python
from peewee import *
DATABASE = 'lullabot'
USER = 'sandbox'
PASSWD = 'sandbox'
mysql_db = MySQLDatabase(DATABASE, user=USER, passwd=PASSWD)
class MySQLModel(Model):
"""A base model that will use our MySQL database"""
class Meta:
database = mysql_db
class client_services(MySQLModel):
"""The client services table"""
first = CharField()
last = CharField()
weight = IntegerField()
mysql_db.connect()
for person in client_services.select().order_by(client_services.weight, fn.Rand()):
if 'last_person' in locals():
print last_person + ' and then ' + person.first
last_person = person.first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment