25bdfd7ca876bf714309c84648317b4a3f7227ce,plantcv-pipeline.py,,db_connect,#Any#,370
Before Change
if os.path.isfile(args.db):
os.remove(args.db)
if os.path.isfile(args.db):
args.connect = sqlite3.connect(args.db)
// Replace the row_factory result constructor with a dictionary constructor
args.connect.row_factory = dict_factory
// Change the text output format from unicode to UTF-8
args.connect.text_factory = str
// Database handler
args.sq = args.connect.cursor()
for row in args.sq.execute("SELECT MAX(run_id) AS max FROM runinfo"):
if row["max"] is not None:
args.run_id = row["max"]
// Get the last run ID
for row in args.sq.execute("SELECT MAX(image_id) AS max FROM metadata"):
if row["max"] is not None:
args.image_id = row["max"]
if os.path.isfile(args.db) == False:
// Connect to the database
args.connect = sqlite3.connect(args.db)
// Replace the row_factory result constructor with a dictionary constructor
After Change
// then we have data in the database and can increment run_id and image_id
runinfo = False
metadata = False
for row in args.sq.execute("SELECT name FROM sqlite_master WHERE type="table""):
if row["name"] == "runinfo":
runinfo = True
elif row["name"] == "metadata":
metadata = True
if runinfo is True and metadata is True:
for row in args.sq.execute("SELECT MAX(run_id) AS max FROM runinfo"):
if row["max"] is not None:
args.run_id = row["max"]
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 5
Instances
Project Name: danforthcenter/plantcv
Commit Name: 25bdfd7ca876bf714309c84648317b4a3f7227ce
Time: 2017-04-05
Author: noahfahlgren@gmail.com
File Name: plantcv-pipeline.py
Class Name:
Method Name: db_connect
Project Name: stratosphereips/StratosphereLinuxIPS
Commit Name: 420d97a98e793964a05a0b5cc9f12781ade39f0d
Time: 2019-06-08
Author: eldraco@gmail.com
File Name: logsProcess.py
Class Name: LogsProcess
Method Name: process_global_data
Project Name: PetrochukM/PyTorch-NLP
Commit Name: def0dfbfbc6f840484a10cc4e963cfa8686ded69
Time: 2018-04-01
Author: petrochukm@gmail.com
File Name: torchnlp/utils.py
Class Name:
Method Name: download_urls
Project Name: nilmtk/nilmtk
Commit Name: 03d22bbb0177117498b3021e068611c6b9421e15
Time: 2014-07-21
Author: oliparson@gmail.com
File Name: nilmtk/dataset_converters/wikienergy/download_wikienergy.py
Class Name:
Method Name: download_wikienergy