Created
December 4, 2012 15:33
-
-
Save noxan/4205198 to your computer and use it in GitHub Desktop.
Ugly python script to create an even uglier oracle db :(
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
import random | |
import string | |
from datetime import date | |
from calendar import monthrange | |
firstnames = list() | |
lastnames = list() | |
def import_names(): | |
f = open('./names.txt') | |
for line in f: | |
firstname, lastname = line.strip().split(' ') | |
firstnames.append(firstname) | |
lastnames.append(lastname) | |
def random_firstname(): | |
return random.choice(firstnames) | |
def random_lastname(): | |
return random.choice(lastnames) | |
def random_name(): | |
return random_firstname() + ' ' + random_lastname() | |
def random_date(): | |
year = random.randint(1900, 2011) | |
month = random.randint(1, 12) | |
return date(year, month, random.randint(*monthrange(year, month))) | |
def random_upperchar(): | |
return random.choice(string.ascii_uppercase) | |
def random_zellentyp(): | |
return random.choice(('Einzelzelle', 'Gruppenzelle')) | |
def random_id(): | |
return random.randint(1, 1000) | |
import_names() | |
class SQL(object): | |
@classmethod | |
def none2null(self, value): | |
if value is None: | |
return u"NULL" | |
return '"'+value+'"' | |
@classmethod | |
def insert_person(self, firstname, lastname, birthday, traktid, zellenid, sozialmassnahme, fortbildungsmassnahme, taetigkeit): | |
return u"INSERT INTO person VALUES ('%s', '%s', to_date('%s', 'yyyy-mm-dd'), %s, %s, %s, %s, %s);" % \ | |
(firstname, lastname, birthday, self.none2null(traktid), self.none2null(zellenid), self.none2null(sozialmassnahme), self.none2null(fortbildungsmassnahme), self.none2null(taetigkeit)) | |
@classmethod | |
def insert_trakt(self, traktid): | |
return u"INSERT INTO trakt (T_ID) VALUES ('%s');" % (traktid) | |
@classmethod | |
def insert_zelle(self, trakt, zellenid, typ): | |
return u"INSERT INTO zelle (Z_Nr, T_ID, Typ) VALUES (%s, '%s', '%s');" % (zellenid, trakt, typ) | |
@classmethod | |
def insert_behandlung(self, medikation, krankheit, arztvn, arztnn, arztgb, haeftlingvn, haeftlingnn, haeftlinggb): | |
return u"INSERT INTO behandlung VALUES ('%s', '%s', '%s', '%s', to_date('%s', 'yyyy-mm-dd'), '%s', '%s', to_date('%s', 'yyyy-mm-ss'));" % (medikation, krankheit, arztvn, arztnn, arztgb, haeftlingvn, haeftlingnn, haeftlinggb) | |
@classmethod | |
def insert_urteil(self, urteilsdatum, delikt, jahre, haeftlingvn, haeftlingnn, haeftlinggb): | |
return u"INSERT INTO urteil VALUES (to_date('%s', 'yyyy-mm-dd'), '%s', %s, '%s', '%s', to_date('%s', 'yyyy-mm-ss'));" % (urteilsdatum, delikt, jahre, haeftlingvn, haeftlingnn, haeftlinggb) | |
print SQL.insert_person(random_firstname(), random_lastname(), random_date(), None, None, None, None, None) | |
print SQL.insert_trakt(random_upperchar()) | |
print SQL.insert_zelle(random_upperchar(), random_id(), random_zellentyp()) |
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
Amie Gaw | |
Mimi Mitton | |
Reid Hadden | |
Jamey Mckissick | |
Marc Mallen | |
Sandy Mcspadden | |
Edris Spradley | |
Marin Lemos | |
Geneva Darlington | |
Avril Boddie | |
Yajaira Groh | |
Vincenza Danna | |
Edythe Fallis | |
Katheryn Pace | |
Cody Forbush | |
Sandee Girouard | |
Deedra Harrel | |
Tynisha Walzer | |
Ramona Cammarata | |
Cleo Dowden | |
Erlinda Ehmann | |
Young Stangl | |
Marcy Bublitz | |
Audrey Solar | |
Ouida Topham | |
Annika Peart | |
Shyla Gerling | |
Jacob Valerio | |
Taren Olander | |
Michael Garren | |
Carter Marino | |
Krishna Ruggieri | |
Edelmira Conder | |
Fidelia Kimbrel | |
Jessie Few | |
Phebe Meunier | |
Gary Garibay | |
Jeanett Lone | |
Vertie Mattingly | |
Serina Gaut | |
Susanne Guzzi | |
Kelsey Yin | |
Obdulia Babbitt | |
Florinda Vandegrift | |
Gil Havis | |
Juliann Lickteig | |
Tobie Hamm | |
Tyree Deyoung | |
Stanley Rosson | |
Lanny Kubiak | |
Avery Zaccaria | |
Tamar Southers | |
Kathe Yard | |
Piedad Rufus | |
Brigitte Ratley | |
Carley Paetzold | |
Pok Nolasco | |
Antonio Szeto | |
Elaina Lundberg | |
Ellis Filiault | |
Yolonda Barren | |
Sharda Medel | |
Flor Mcdougal | |
Jodee Herrera | |
Christopher Record | |
Janee Gula | |
Juanita Updike | |
Wilbur Leet | |
Janett Rutkowski | |
Vincent Rady | |
Evie Leisinger | |
Audrie Bridgett | |
Katharyn Bochenek | |
Fawn Adams | |
Tristan Stillwell | |
Loren Hardison | |
Gavin Creswell | |
Jesica Coit | |
Sibyl Bullock | |
Benedict Vong | |
Mika Banner | |
Winona Racca | |
Tory Palazzo | |
Maude Bridgeforth | |
Cassaundra Bolster | |
Lashell Markel | |
Lavonne Groover | |
Shala Terranova | |
Carlo Lagrange | |
Trish Swanson | |
Gwenda Martir | |
Ngan Hathorn | |
Myung Mitchel | |
Gretta Ulm | |
Shane Grasser | |
Ona Stivers | |
Arcelia Pedroso | |
Thao Stancil | |
Venita Mcphearson | |
Maudie Smithers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment