5781247080c97e4aba9aba2afb39686b5f9419a2 max Wed Jan 22 07:50:46 2014 -0800 fixing .as files, refs #12212 diff --git src/oneShot/sqlToAs/sqlToAs src/oneShot/sqlToAs/sqlToAs index ba183bd..e2c317c 100755 --- src/oneShot/sqlToAs/sqlToAs +++ src/oneShot/sqlToAs/sqlToAs @@ -1,21 +1,18 @@ #!/usr/bin/env python import logging, optparse, sys -# do not modify this file, modify the original in kent/src/oneShot/sqlToAs -# and commit the changes - # === COMMAND LINE INTERFACE, OPTIONS AND HELP === parser = optparse.OptionParser("usage: %prog [options] - convert mysql .sql CREATE TABLE file to autoSql format") parser.add_option("-d", "--debug", dest="debug", action="store_true", help="show debug messages") (options, args) = parser.parse_args() if options.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) # ----------- MAIN -------------- if args==[]: parser.print_help() sys.exit(1) @@ -49,31 +46,32 @@ for line in open(filename).read().splitlines(): line = line.strip() lowLine = line.lower() logging.debug(line) if len(line)<=3: continue if line.startswith("#"): if tableCommentDone: continue tableComment = '"%s"' % line.strip().strip("#") tableCommentDone = True elif line.startswith("CREATE TABLE"): name = line.split()[2].strip("`") tableLine = "table %s" % name continue - elif lowLine.startswith("key") or lowLine.startswith("primary") or lowLine.startswith("fulltext"): + elif lowLine.startswith("key") or lowLine.startswith("primary") or lowLine.startswith("fulltext") \ + or "character set" in lowLine: continue # `chrom` varchar(255) NOT NULL, # chromosome # `start` int unsigned NOT NULL, # start else: parts = line.split() fieldName, sqlType = parts[:2] # special case for integers if len(parts)>2 and "signed" in parts[2]: sqlType=sqlType+" "+parts[2] fieldName = fieldName.strip("`") if sqlType.startswith("char"): asType = sqlType.replace("(","[").replace(")","]")