ID,Name,HP,Attack,Defense,Sp. Atk,Sp. Def,Speed,Generation,Legendary 1,Bulbasaur,45,49,49,65,65,45,1,FALSE 2,Ivysaur,60,62,63,80,80,60,1,FALSE
TypeID, TypeName 1,Bug 2,Dark 3,Dragon
CardID,TypeID 14,1 15,1 16,1 17,1
#!/usr/bin/python
# need to use the correct database
print "USE PokemonDB;"
# SQL command to insert the data
print "INSERT INTO TypeTable (TypeID, TypeName) VALUES"
dbfile = open("TypeTable.csv");
# I need this so
# I can skip the first line
# I can print comma after all but last line.
lineNo = 0;
for line in dbfile:
if lineNo == 0:
lineNo +=1;
else:
# add a comma after a line has been printed, not the first line
if lineNo > 1:
print ","
(tid,name) = line.split(',');
print '('+tid+',"'+name.strip()+'")',
lineNo +=1;
# print a semicolon after the last line
print ";"
USE PokemonDB; INSERT INTO TypeTable (TypeID, TypeName) VALUES (0,"") , (1,"Bug") , (2,"Dark") , ... (19,"Water") ;
source build.sql source cards.sql source types.sql source cardType.sql
#!/bin/bash python cardMaker.py > cards.sql python cardTypeMaker.py > cardType.sql python typeMaker.py > types.sql mysql -u dsciAdmin -p -s < PokymonDB.sql