aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/maintenance')
-rw-r--r--wqflask/maintenance/dataset/load_phenotypes.py29
-rw-r--r--wqflask/maintenance/dataset/utilities.py4
2 files changed, 17 insertions, 16 deletions
diff --git a/wqflask/maintenance/dataset/load_phenotypes.py b/wqflask/maintenance/dataset/load_phenotypes.py
index 6e7f049b..c47453b7 100644
--- a/wqflask/maintenance/dataset/load_phenotypes.py
+++ b/wqflask/maintenance/dataset/load_phenotypes.py
@@ -11,7 +11,7 @@ def main(argv):
print "\t%s" % (str(item))
# var
inbredsetid = config.get('config', 'inbredsetid')
- cursor = utilities.get_cursor()
+ cursor, con = utilities.get_cursor()
print "inbredsetid: %s" % inbredsetid
# datafile
datafile = open(config.get('config', 'datafile'), 'r')
@@ -45,20 +45,21 @@ def main(argv):
Phenotype.`Units`=%s
"""
cursor.execute(sql, (
- metarow[1],
- metarow[2],
- metarow[3],
- metarow[4],
- metarow[5],
- metarow[6],
- metarow[7],
- metarow[8],
- metarow[9],
- metarow[18]
+ utilities.to_db_string_null(metarow[1]),
+ utilities.to_db_string_null(metarow[2]),
+ utilities.to_db_string_null(metarow[3]),
+ utilities.to_db_string_null(metarow[4]),
+ utilities.to_db_string_null(metarow[5]),
+ utilities.to_db_string_null(metarow[6]),
+ utilities.to_db_string_null(metarow[7]),
+ utilities.to_db_string_null(metarow[8]),
+ utilities.to_db_string_null(metarow[9]),
+ utilities.to_db_string_null(metarow[18])
))
- re = cursor.rowcount
- print "INSERT INTO Phenotype: %d record" % re
-
+ rowcount = cursor.rowcount
+ phenotypeid = con.insert_id()
+ print "INSERT INTO Phenotype: %d record: %d" % (rowcount, phenotypeid)
+
if __name__ == "__main__":
print "command line arguments:\n\t%s" % sys.argv
main(sys.argv)
diff --git a/wqflask/maintenance/dataset/utilities.py b/wqflask/maintenance/dataset/utilities.py
index e542cb43..fac24943 100644
--- a/wqflask/maintenance/dataset/utilities.py
+++ b/wqflask/maintenance/dataset/utilities.py
@@ -9,8 +9,8 @@ def get_cursor():
db = 'db_webqtl'
con = MySQLdb.Connect(db=db, host=host, user=user, passwd=passwd)
cursor = con.cursor()
- return cursor
-
+ return cursor, con
+
def clearspaces(s, default=None):
if s:
s = re.sub('\s+', ' ', s)