added code to extract skill data from MySQL version of CCP database dump, as well...
authorDanny Campbell <danny.campbell@gmail.com>
Fri, 16 Apr 2010 13:22:19 +0000 (07:22 -0600)
committerDanny Campbell <danny.campbell@gmail.com>
Fri, 16 Apr 2010 13:22:19 +0000 (07:22 -0600)
data/invTypes.sqlite [new file with mode: 0644]
data/mysql2sqlite.py [new file with mode: 0644]
data/skill_lookup.py [new file with mode: 0644]
data/table_structure.sql [new file with mode: 0644]

diff --git a/data/invTypes.sqlite b/data/invTypes.sqlite
new file mode 100644 (file)
index 0000000..38a4346
Binary files /dev/null and b/data/invTypes.sqlite differ
diff --git a/data/mysql2sqlite.py b/data/mysql2sqlite.py
new file mode 100644 (file)
index 0000000..b35e0f5
--- /dev/null
@@ -0,0 +1,29 @@
+# mysql2sqlite: a program written, composed, and directed by danny campbell because sqlite and mysql are apparently too stupid to talk to each other. Possibly too stupid to live. --danny
+
+import MySQLdb
+import sqlite3
+
+# dominion dump from here: (mysql singlefile) http://www.eveonline.com/ingameboard.asp?a=topic&threadID=1258009
+# didn't use the sqlite singlefile because I only needed a tiny drop of the DB for the skil information. --danny
+mysqldb = MySQLdb.connect( user = "root", passwd = "password", db = "dominion_dump" )
+
+# grab all the group types that belong to category type 16. probably shouldn't hardcode these... --danny
+mysqlc = mysqldb.cursor()
+mysqlc.execute( """SELECT * FROM `invTypes` WHERE `groupID` = 255 OR `groupID` = 256 OR `groupID` = 257 OR `groupID` = 258 OR `groupID` = 266 OR `groupID` = 267 OR `groupID` = 268 OR `groupID` = 269 OR `groupID` = 270 OR `groupID` = 271 OR `groupID` = 272 OR `groupID` = 273 OR `groupID` = 274 OR `groupID` = 275 OR `groupID` = 278 OR `groupID` = 505 OR `groupID` = 989""" )
+
+# grab all rows from the query. --danny
+skills = mysqlc.fetchall()
+
+mysqlc.close()
+
+# add error checking, danny! --danny
+sqliteconn = sqlite3.connect( '/tmp/invTypes.sqlite' )
+sqlitec = sqliteconn.cursor()
+
+# the question marks just fill in the blanks using the tuple --danny
+for skill in skills:
+    sqlitec.execute( 'INSERT INTO invTypes VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )', skill )
+
+# why don't I need to commit on MySQLdb? --danny
+sqliteconn.commit()
+sqlitec.close()
diff --git a/data/skill_lookup.py b/data/skill_lookup.py
new file mode 100644 (file)
index 0000000..41851f8
--- /dev/null
@@ -0,0 +1,26 @@
+# skill_lookup.py: initialize it with the typeID from the XML file, and it will fetch the information we need that we can't find in the API, from the SQLite skills database I made. --danny
+
+import sqlite3
+
+class db_skill():
+    
+    def __init__( self, type_id ):
+
+        # open the custom skill dump from cur dir. --danny
+        conn = sqlite3.connect( './invTypes.sqlite' )
+        c = conn.cursor()
+        
+        # create a tuple out of the typeID --danny
+        t = ( type_id, )
+        c.execute( 'SELECT typeName, description, graphicID FROM invTypes WHERE typeID = ?', t )
+        # break up the tuple returned --danny
+        ( self.sk_name, self.sk_desc, self.sk_graphic_id ) = c.fetchone()
+        c.close()
+
+    # ( I don't even know if this how you should do this sort of thing, just playing around with classes.) --danny
+
+    def get_name( self ):
+        return self.sk_name
+
+    def get_desc( self ):
+        return self.sk_desc
diff --git a/data/table_structure.sql b/data/table_structure.sql
new file mode 100644 (file)
index 0000000..6423557
--- /dev/null
@@ -0,0 +1,17 @@
+CREATE TABLE invTypes (
+  typeID smallint(6) NOT NULL,
+  groupID smallint(6) default NULL,
+  typeName varchar(100) default NULL,
+  description varchar(3000) default NULL,
+  graphicID smallint(6) default NULL,
+  radius double default NULL,
+  mass double default NULL,
+  volume double default NULL,
+  capacity double default NULL,
+  portionSize int(11) default NULL,
+  raceID tinyint(3) default NULL,
+  basePrice double default NULL,
+  published tinyint(1) default NULL,
+  marketGroupID smallint(6) default NULL,
+  chanceOfDuplicating double default NULL
+);