Created
July 8, 2013 06:08
-
-
Save q0rban/5946539 to your computer and use it in GitHub Desktop.
My first python script!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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