本文整理汇总了Python中Classes.SUDBConnect.SUDBConnect.insertUpdateOrDeleteDB方法的典型用法代码示例。如果您正苦于以下问题:Python SUDBConnect.insertUpdateOrDeleteDB方法的具体用法?Python SUDBConnect.insertUpdateOrDeleteDB怎么用?Python SUDBConnect.insertUpdateOrDeleteDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classes.SUDBConnect.SUDBConnect
的用法示例。
在下文中一共展示了SUDBConnect.insertUpdateOrDeleteDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_normalRun
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def test_normalRun(self):
# set up
db = SUDBConnect()
sponsorsList = []
descriptionList = []
ocList = []
iefaLeadTrainingIdList = []
actualBad = []
concatenatedDescriptionOCList = []
rows = db.getRowsDB("select * from dbo.IefaLeadsTrainingItems where BadScholarship!='Maybe'")
for row in rows:
sponsorsList.append(row.Sponsor)
descriptionList.append(row.Description)
ocList.append(row.OtherCriteria)
actualBad.append(row.BadScholarship)
iefaLeadTrainingIdList.append(str(row.IefaLeadTrainingId))
for i in range(len(descriptionList)):
conatenatedItem = '%s %s' % (descriptionList[i], ocList[i])
concatenatedDescriptionOCList.append(conatenatedItem)
# test
testNER = ClassifyBadScholarships(sponsorsList, concatenatedDescriptionOCList)
predictedBad = testNER.loopThroughLeadsAndDoStuff()
accuracy = ComputeAccuracy(actualBad, predictedBad).calculateAccuracy()
print(accuracy)
# put result in db
for i in range(len(predictedBad)):
iefaLeadTrainingId = iefaLeadTrainingIdList[i]
predicted = predictedBad[i]
db.insertUpdateOrDeleteDB(
"update dbo.IefaLeadsTrainingItems set NormalTestPredictedTag='" + predicted + "' where IefaLeadTrainingId='" + iefaLeadTrainingId + "'")
示例2: test_InsertPivotLeadsArrayIntoPivotLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def test_InsertPivotLeadsArrayIntoPivotLeadsDB(self):
fakepivotleadsarray = ['keyword', 'url', 'name', 'abstract', 'sponsor', 'amount', 'applicant type',
'citizenship residency', 'activity location', 'eligibility', 'categories',
'source website', 'source text']
InsertPivotLeadsArrayIntoPivotLeadsDB(fakepivotleadsarray)
db = SUDBConnect()
rows = db.getRowsDB("select * from dbo.PivotLeads where Url='url'")
self.assertIsNotNone(rows)
self.assertEqual('keyword', rows[0].Keyword)
self.assertEqual('url', rows[0].Url)
self.assertEqual('name', rows[0].Name)
self.assertEqual('abstract', rows[0].Abstract)
self.assertEqual('sponsor', rows[0].Sponsor)
self.assertEqual('amount', rows[0].Amount)
self.assertEqual('applicant type', rows[0].ApplicantType)
self.assertEqual('citizenship residency', rows[0].CitizenshipResidency)
self.assertEqual('activity location', rows[0].ActivityLocation)
self.assertEqual('eligibility', rows[0].Eligibility)
self.assertEqual('categories', rows[0].Categories)
self.assertEqual('source website', rows[0].SourceWebsite)
self.assertEqual('source text', rows[0].SourceText)
db.insertUpdateOrDeleteDB("delete from dbo.PivotLeads where Url='url'")
示例3: InsertUnigoLeadArrayIntoUnigoLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertUnigoLeadArrayIntoUnigoLeadsDB(object):
def __init__(self, unigoLeadArray, fundingClassification, badScholarshipClassification):
self.unigoLeadArray = unigoLeadArray
self.fundingClassification = fundingClassification
self.badScholarshipClassification = badScholarshipClassification
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.name = self.unigoLeadArray[0]
self.amount = self.unigoLeadArray[1]
self.deadline = self.unigoLeadArray[2]
self.url = self.unigoLeadArray[3]
self.url = re.sub("'", '', self.url)
self.sponsor = self.unigoLeadArray[4]
self.awardAmount = self.unigoLeadArray[5]
self.recipients = self.unigoLeadArray[6]
self.requirements = self.unigoLeadArray[7]
self.additionalInfo = self.unigoLeadArray[8]
self.contact = self.unigoLeadArray[9]
self.address = self.unigoLeadArray[10]
self.deadlineInformation = self.unigoLeadArray[11]
self.sourceWebsite = self.unigoLeadArray[12]
self.sourceWebsite = re.sub("'", '', self.sourceWebsite)
self.sourceText = self.unigoLeadArray[13]
self.date = time.strftime('%Y%m%d')
def checkIfAlreadyInDatabase(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.UnigoLeads where Name='" + self.name + "' and Url='" + self.url + "'")
# "select * from dbo.UnigoLeads where Name='" + self.name + "' and Url='" + self.url + "'"
if matchingRow != []:
return True
else:
return False
def writeFileToDisk(self):
tableName = 'UnigoLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.UnigoLeads where Name='" + self.name + "' and Url='" + self.url + "'")[
0]
# "select * from dbo.UnigoLeads where Name='" + self.name + "' and Url='" + self.url + "'"
self.fileSystemDB.writeFile(columns, currentRow, user, website, self.url, self.date)
def insertUpdateLead(self):
if not self.checkIfAlreadyInDatabase():
self.db.insertUpdateOrDeleteDB(
"INSERT INTO dbo.UnigoLeads (Name, Amount, Deadline, Url, Sponsor, AwardAmount, Recipients, Requirements, AdditionalInfo, Contact, Address, DeadlineInformation, SourceWebsite, SourceText, Tag, BadScholarship, Date) VALUES (N'" + self.name + "', N'" + self.amount + "', N'" + self.deadline + "', N'" + self.url + "', N'" + self.sponsor + "', N'" + self.awardAmount + "', N'" + self.recipients + "', N'" + self.requirements + "', N'" + self.additionalInfo + "', N'" + self.contact + "', N'" + self.address + "', N'" + self.deadlineInformation + "', N'" + self.sourceWebsite + "', N'" + self.sourceText + "', N'" + self.fundingClassification + "', N'" + self.badScholarshipClassification + "', '" + self.date + "')")
self.writeFileToDisk()
return True
else:
self.db.insertUpdateOrDeleteDB(
"UPDATE dbo.UnigoLeads SET Amount=N'" + self.amount + "', Deadline=N'" + self.deadline + "', Sponsor=N'" + self.sponsor + "', AwardAmount=N'" + self.awardAmount + "', Recipients=N'" + self.recipients + "', Requirements=N'" + self.requirements + "', AdditionalInfo=N'" + self.additionalInfo + "', Contact=N'" + self.contact + "', Address=N'" + self.address + "', DeadlineInformation=N'" + self.deadlineInformation + "', SourceWebsite=N'" + self.sourceWebsite + "', SourceText=N'" + self.sourceText + "', Tag=N'" + self.fundingClassification + "', BadScholarship=N'" + self.badScholarshipClassification + "', Date='" + self.date + "' WHERE Name=N'" + self.name + "' AND Url='" + self.url + "'")
# UPDATE dbo.UnigoLeads SET Amount=N'" + self.amount + "', Deadline=N'" + self.deadline + "', Url='" + self.url + "', Sponsor=N'" + self.sponsor + "', AwardAmount=N'" + self.awardAmount + "', Recipients=N'" + self.recipients + "', Requirements=N'" + self.requirements + "', AdditionalInfo=N'" + self.additionalInfo + "', Contact=N'" + self.contact + "', Address=N'" + self.address + "', DeadlineInformation=N'" + self.deadlineInformation + "', SourceText=N'" + self.sourceText + "', Tag=N'" + self.fundingClassification + "', BadScholarship=N'" + self.badScholarshipClassification + "', Date='" + self.date + "' WHERE Name=N'" + self.name + "' AND SourceWebsite=N'" + self.sourceWebsite + "'
# UPDATE dbo.UnigoLeads SET Amount=N'" + self.amount + "', Deadline=N'" + self.deadline + "', Sponsor=N'" + self.sponsor + "', AwardAmount=N'" + self.awardAmount + "', Recipients=N'" + self.recipients + "', Requirements=N'" + self.requirements + "', AdditionalInfo=N'" + self.additionalInfo + "', Contact=N'" + self.contact + "', Address=N'" + self.address + "', DeadlineInformation=N'" + self.deadlineInformation + "', SourceWebsite=N'" + self.sourceWebsite + "', SourceText=N'" + self.sourceText + "', Tag=N'" + self.fundingClassification + "', BadScholarship=N'" + self.badScholarshipClassification + "', Date='" + self.date + "' WHERE Name=N'" + self.name + "' AND Url=N'" + self.url + "'
self.writeFileToDisk()
return False
示例4: __init__
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def __init__(self, googleLeadArray):
self.googleLeadArray = googleLeadArray
db = SUDBConnect()
title = self.googleLeadArray[0]
link = self.googleLeadArray[1]
description = self.googleLeadArray[2]
db.insertUpdateOrDeleteDB(
"INSERT INTO dbo.GoogleLeads (GoogleLeadId, KeyTerm, Title, Link, Description, LinkBody, DateLeadGenerated, DateBodyGenerated) VALUES (0 , '', '" + title + "', '" + link + "', '" + description + "', '', GETDATE(), GETDATE())")
示例5: doInsert
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def doInsert(GoogleLeadArray):
db = SUDBConnect()
title = GoogleLeadArray[0]
url = GoogleLeadArray[1]
description = GoogleLeadArray[2]
db.insertUpdateOrDeleteDB(
"INSERT INTO dbo.LinkCrawlerHrefs ( QuestionId, LinkUrl, LinkName, LinkDescription, LinkBody, ProcessUsed, IsBadLink, InsertDate, UpdateDate) VALUES ( 0, '" + url + "', '" + title + "', '" + description + "', '', 0, 0, GETDATE(), GETDATE())")
return None
示例6: InsertScholarsiteLeadsArrayIntoScholarsiteLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertScholarsiteLeadsArrayIntoScholarsiteLeadsDB(object):
def __init__(self, scholarsiteLeadArray, fundingClassification, badScholarshipClassification):
self.scholarsiteLeadArray = scholarsiteLeadArray
self.fundingClassification = fundingClassification
self.badScholarshipClassificaion = badScholarshipClassification
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.name = self.scholarsiteLeadArray[0]
self.amount = self.scholarsiteLeadArray[1]
self.deadline = self.scholarsiteLeadArray[2]
self.requirements = self.scholarsiteLeadArray[3]
self.annualAwards = self.scholarsiteLeadArray[4]
self.major = self.scholarsiteLeadArray[5]
self.academicLevel = self.scholarsiteLeadArray[6]
self.qualifiedMinorities = self.scholarsiteLeadArray[7]
self.eligibleInstitution = self.scholarsiteLeadArray[8]
self.eligibleRegion = self.scholarsiteLeadArray[9]
self.usCitizen = self.scholarsiteLeadArray[10]
self.usResident = self.scholarsiteLeadArray[11]
self.foreignNational = self.scholarsiteLeadArray[12]
self.minimumAge = self.scholarsiteLeadArray[13]
self.maximumAge = self.scholarsiteLeadArray[14]
self.classRank = self.scholarsiteLeadArray[15]
self.minimumGPA = self.scholarsiteLeadArray[16]
self.minimumACT = self.scholarsiteLeadArray[17]
self.minimumSAT = self.scholarsiteLeadArray[18]
self.date = time.strftime('%Y%m%d')
def checkIfAlreadyInDB(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.ScholarsiteLeads where Name='" + self.name + "'")
if matchingRow != []:
return True
else:
return False
def writeFileToDisk(self):
tableName = 'ScholarsiteLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.ScholarsiteLeads where Name='" + self.name + "'")[0]
self.fileSystemDB.writeFile(columns, currentRow, user, website, '', self.date)
def insertUpdateLead(self):
if not self.checkIfAlreadyInDB():
self.db.insertUpdateOrDeleteDB(
"insert into dbo.ScholarsiteLeads (Name, Amount, Deadline, Requirements, AnnualAwards, Major, AcademicLevel, QualifiedMinorities, EligibleInstitution, EligibleRegion, USCitizen, USResident, ForeignNational, MinimumAge, MaximumAge, ClassRank, MinimumGPA, MinimumACT, MinimumSAT, Tag, BadScholarship, Date) values (N'" + self.name + "', N'" + self.amount + "', '" + self.deadline + "', N'" + self.requirements + "', N'" + self.annualAwards + "', N'" + self.major + "', N'" + self.academicLevel + "', N'" + self.qualifiedMinorities + "', N'" + self.eligibleInstitution + "', N'" + self.eligibleRegion + "', N'" + self.usCitizen + "', N'" + self.usResident + "', N'" + self.foreignNational + "', '" + self.minimumAge + "', '" + self.maximumAge + "', N'" + self.classRank + "', N'" + self.minimumGPA + "', N'" + self.minimumACT + "', N'" + self.minimumSAT + "', N'" + self.fundingClassification + "', '" + self.badScholarshipClassificaion + "', '" + self.date + "')")
self.writeFileToDisk()
return True
else:
self.db.insertUpdateOrDeleteDB(
"update dbo.ScholarsiteLeads set Amount=N'" + self.amount + "', Deadline=N'" + self.deadline + "', Requirements=N'" + self.requirements + "', AnnualAwards='" + self.annualAwards + "', Major='" + self.major + "', AcademicLevel=N'" + self.academicLevel + "', QualifiedMinorities=N'" + self.qualifiedMinorities + "', EligibleInstitution=N'" + self.eligibleInstitution + "', EligibleRegion=N'" + self.eligibleRegion + "', USCitizen='" + self.usCitizen + "', USResident='" + self.usResident + "', ForeignNational='" + self.foreignNational + "', MinimumAge='" + self.minimumAge + "', MaximumAge='" + self.maximumAge + "', ClassRank='" + self.classRank + "', MinimumGPA='" + self.minimumGPA + "', MinimumACT='" + self.minimumACT + "', MinimumSAT='" + self.minimumSAT + "', Tag='" + self.fundingClassification + "', BadScholarship='" + self.badScholarshipClassificaion + "', Date='" + self.date + "' where Name='" + self.name + "'")
self.insertUpdateLead()
return False
示例7: test_InsertScholarshipArrayIntoDatabase
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def test_InsertScholarshipArrayIntoDatabase(self):
db = SUDBConnect()
db.insertUpdateOrDeleteDB(
"delete from dbo.LinkCrawlerHrefs where linkurl='http://colleges.fastweb.com/d-foreign-languages-literatures-and-linguistics'")
InsertScholarshipArrayIntoDatabase.doInsert(PullPageLinkTitleDescriptionToArray(
'http://colleges.fastweb.com/d-foreign-languages-literatures-and-linguistics').doArray())
rows = db.getRowsDB(
"select * from LinkCrawlerHrefs where linkurl='http://colleges.fastweb.com/d-foreign-languages-literatures-and-linguistics'")
self.assertEqual(rows[0].LinkUrl, 'http://colleges.fastweb.com/d-foreign-languages-literatures-and-linguistics')
示例8: InsertIefaLeadArrayIntoIefaLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertIefaLeadArrayIntoIefaLeadsDB(object):
def __init__(self, iefaLeadArray, fundingClassification, badScholarshipClassification):
self.iefaLeadArray = iefaLeadArray
self.fundingClassification = fundingClassification
self.badScholarshipClassificaion = badScholarshipClassification
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.name = self.iefaLeadArray[0]
self.url = self.iefaLeadArray[1]
self.url = CleanText.replaceSingleQuotesWithTwoSingleQuotes(self.url)
self.sponsor = self.iefaLeadArray[2]
self.submissionDeadline = self.iefaLeadArray[3]
self.majors = self.iefaLeadArray[4]
self.amount = self.iefaLeadArray[5]
self.description = self.iefaLeadArray[6]
self.otherCriteria = self.iefaLeadArray[7]
self.numberAwards = self.iefaLeadArray[8]
self.hostInstitution = self.iefaLeadArray[9]
self.includes = self.iefaLeadArray[10]
self.nationalityRequired = self.iefaLeadArray[11]
self.hostCountries = self.iefaLeadArray[12]
self.sourceWebsite = self.iefaLeadArray[13]
self.sourceText = self.iefaLeadArray[14]
self.date = time.strftime('%Y%m%d')
def writeFileToDisk(self):
tableName = 'IefaLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.IefaLeads where Name='" + self.name + "' and Url='" + self.url + "'")[0]
self.fileSystemDB.writeFile(columns, currentRow, user, website, self.url, self.date)
def checkIfAlreadyInDatabase(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.IefaLeads where Name='" + self.name + "' and Url='" + self.url + "'")
if matchingRow != []:
return True
else:
return False
def insertUpdateLead(self):
if not self.checkIfAlreadyInDatabase():
self.db.insertUpdateOrDeleteDB(
"INSERT INTO dbo.IefaLeads (Name, Url, Sponsor, SubmissionDeadline, Majors, Amount, Description, OtherCriteria, NumberAwards, HostInstitution, Includes, NationalityRequired, HostCountries, SourceWebsite, SourceText, Date, Tag, BadScholarship) VALUES (N'" + self.name + "', N'" + self.url + "', N'" + self.sponsor + "', N'" + self.submissionDeadline + "', N'" + self.majors + "', N'" + self.amount + "', N'" + self.description + "', N'" + self.otherCriteria + "', N'" + self.numberAwards + "', N'" + self.hostInstitution + "', N'" + self.includes + "', N'" + self.nationalityRequired + "', N'" + self.hostCountries + "', N'" + self.sourceWebsite + "', N'" + self.sourceText + "', '" + self.date + "', '" + self.fundingClassification + "', '" + self.badScholarshipClassificaion + "')")
self.writeFileToDisk()
else:
self.db.insertUpdateOrDeleteDB(
"update dbo.IefaLeads set Sponsor=N'" + self.sponsor + "', SubmissionDeadline=N'" + self.submissionDeadline + "', Majors=N'" + self.majors + "', Amount=N'" + self.amount + "', Description=N'" + self.description + "', OtherCriteria=N'" + self.otherCriteria + "', NumberAwards=N'" + self.numberAwards + "', HostInstitution=N'" + self.hostInstitution + "', Includes=N'" + self.includes + "', NationalityRequired=N'" + self.nationalityRequired + "', HostCountries=N'" + self.hostCountries + "', SourceWebsite=N'" + self.sourceWebsite + "', SourceText=N'" + self.sourceText + "', Date='" + self.date + "', Tag='" + self.fundingClassification + "', BadScholarship='" + self.badScholarshipClassificaion + "' where Name='" + self.name + "' and Url='" + self.url + "'")
self.writeFileToDisk()
示例9: InsertGrantForwardLeadsArrayIntoGrantForwardItems
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertGrantForwardLeadsArrayIntoGrantForwardItems(object):
def __init__(self, grantForwardLeadArray, fundingClassification, badScholarshipClassification):
self.grantForwardLeadArray = grantForwardLeadArray
self.fundingClassification = fundingClassification
self.badScholarshipClassification = badScholarshipClassification
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.keyword = self.grantForwardLeadArray[0]
self.url = self.grantForwardLeadArray[1]
self.name = self.grantForwardLeadArray[2]
self.description = self.grantForwardLeadArray[3]
self.sponsor = self.grantForwardLeadArray[4]
self.amount = self.grantForwardLeadArray[5]
self.eligibility = self.grantForwardLeadArray[6]
self.submissionInfo = self.grantForwardLeadArray[7]
self.categories = self.grantForwardLeadArray[8]
self.sourceWebsite = self.grantForwardLeadArray[9]
self.sourceText = self.grantForwardLeadArray[10]
self.deadline = self.grantForwardLeadArray[11]
self.date = time.strftime('%Y%m%d')
def checkIfAlreadyInDatabase(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.GrantForwardLeads where Keyword='" + self.keyword + "' and Url='" + self.url + "'")
if matchingRow != []:
return True
else:
return False
def writeFileToDisk(self):
tableName = 'GrantForwardLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.GrantForwardLeads where Keyword='" + self.keyword + "' and Url='" + self.url + "'")[
0]
self.fileSystemDB.writeFile(columns, currentRow, user, website, self.url, self.date)
def insertUpdateLead(self):
if not self.checkIfAlreadyInDatabase():
self.db.insertUpdateOrDeleteDB(
"INSERT INTO dbo.GrantForwardLeads (Name, Url, Keyword, Description, Sponsor, Amount, Eligibility, SubmissionInfo, Categories, SourceWebsite, SourceText, Deadline, FundingClassification, BadScholarship, Date) VALUES (N'" + self.name + "', N'" + self.url + "', N'" + self.keyword + "', N'" + self.description + "', N'" + self.sponsor + "', N'" + self.amount + "', N'" + self.eligibility + "', N'" + self.submissionInfo + "', N'" + self.categories + "', N'" + self.sourceWebsite + "', N'" + self.sourceText + "', N'" + self.deadline + "', N'" + self.fundingClassification + "', N'" + self.badScholarshipClassification + "', '" + self.date + "')")
self.writeFileToDisk()
return True
else:
self.db.insertUpdateOrDeleteDB(
"update dbo.GrantForwardLeads set Name=N'" + self.name + "', Description=N'" + self.description + "', Sponsor=N'" + self.sponsor + "', Amount=N'" + self.amount + "', Eligibility=N'" + self.eligibility + "', SubmissionInfo=N'" + self.submissionInfo + "', Categories=N'" + self.categories + "', SourceWebsite='" + self.sourceWebsite + "', SourceText=N'" + self.sourceText + "', Deadline=N'" + self.deadline + "', FundingClassification='" + self.fundingClassification + "', BadScholarship='" + self.badScholarshipClassification + "', Date='" + self.date + "' where Keyword='" + self.keyword + "' and Url='" + self.url + "'")
self.writeFileToDisk()
return False
示例10: InsertFastWebLeadIntoFastWebLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertFastWebLeadIntoFastWebLeadsDB(object):
def __init__(self, fastWebLeadArray, fundingClassification, badScholarshipClassification):
self.badScholarshipClassification = badScholarshipClassification
self.fundingClassification = fundingClassification
self.fastWebLeadArray = fastWebLeadArray
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.name = self.fastWebLeadArray[0]
self.url = self.fastWebLeadArray[1]
self.sponsor = self.fastWebLeadArray[2]
self.amount = self.fastWebLeadArray[3]
self.deadline = self.fastWebLeadArray[4]
self.description = self.fastWebLeadArray[5]
self.awardType = self.fastWebLeadArray[6]
self.numAwards = self.fastWebLeadArray[7]
self.majors = self.fastWebLeadArray[8]
self.additionalInfo = self.fastWebLeadArray[9]
self.sourceWebsite = self.fastWebLeadArray[10]
self.sourceText = self.fastWebLeadArray[11]
self.date = time.strftime('%Y%m%d')
def writeFileToDisk(self):
tableName = 'FastWebLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.FastWebLeads where Name='" + self.name + "' and Url='" + self.url + "'")[0]
self.fileSystemDB.writeFile(columns, currentRow, user, website, self.url, self.date)
def checkIfAlreadyInDatabase(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.FastWebLeads where Name='" + self.name + "' and Url='" + self.url + "'")
if matchingRow != []:
return True
else:
return False
def insertUpdateLead(self):
if not self.checkIfAlreadyInDatabase():
self.db.insertUpdateOrDeleteDB(
"insert into dbo.FastWebLeads (Name, Url, Sponsor, Amount, Deadline, Description, AwardType, NumAwards, Majors, AdditionalInfo, SourceWebsite, SourceText, Date, Tag, BadScholarship) values (N'" + self.name + "', N'" + self.url + "', N'" + self.sponsor + "', N'" + self.amount + "', N'" + self.deadline + "', N'" + self.description + "', N'" + self.awardType + "', N'" + self.numAwards + "', N'" + self.majors + "', N'" + self.additionalInfo + "', N'" + self.sourceWebsite + "', N'" + self.sourceText + "', '" + self.date + "', '" + self.fundingClassification + "', '" + self.badScholarshipClassification + "')")
self.writeFileToDisk()
return True
else:
self.db.insertUpdateOrDeleteDB(
"update dbo.FastWebLeads set Sponsor='" + self.sponsor + "', Amount='" + self.amount + "', Deadline='" + self.deadline + "', Description='" + self.description + "', AwardType='" + self.awardType + "', NumAwards='" + self.numAwards + "', Majors='" + self.majors + "', AdditionalInfo='" + self.additionalInfo + "', SourceWebsite='" + self.sourceWebsite + "', SourceText='" + self.sourceText + "', Date='" + self.date + "', Tag='" + self.fundingClassification + "', BadScholarship='" + self.badScholarshipClassification + "' where Name='" + self.name + "' and Url='" + self.url + "'")
self.writeFileToDisk()
return False
示例11: ClassifyPotentialScholarshipsClassStatus
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class ClassifyPotentialScholarshipsClassStatus(object):
def __init__(self, whichHalfToDo):
self.whichHalfToDo = whichHalfToDo
self.db = SUDBConnect()
self.rows = self.db.getRowsDB("select * from dbo.ClassifiedPotentialScholarships")
self.oneVsRestPretrainedModelFile = 'OneVsRestLRTrainedClassifiers/OneVsRestLRTrainedModel'
self.oneVsRestPretrainedFeaturesValueCountsFile = 'OneVsRestLRTrainedClassifiers/OneVsRestLRTrainedFeaturesValueCounts'
self.dataTextList = self.getDataTextList()
self.potentialScholarshipIdsList = self.getScholarshipIdsList()
halfOfRows = math.ceil(len(self.dataTextList) * 0.5)
if self.whichHalfToDo == 1:
self.dataTextList = self.dataTextList[:halfOfRows]
self.potentialScholarshipIdsList = self.potentialScholarshipIdsList[:halfOfRows]
elif self.whichHalfToDo == 2:
self.dataTextList = self.dataTextList[-halfOfRows:]
self.potentialScholarshipIdsList = self.potentialScholarshipIdsList[-halfOfRows:]
self.OneVsRestClassifier = OneVsRestClassifyFromPretrainedModel(self.oneVsRestPretrainedModelFile,
self.oneVsRestPretrainedFeaturesValueCountsFile,
self.dataTextList,
self.potentialScholarshipIdsList)
self.predictedClassStatuses = self.OneVsRestClassifier.getPredictions()
self.insertResultsIntoDB()
def getDataTextList(self):
dataTextList = []
for row in self.rows:
dataTextList.append(row.Description)
return dataTextList
def getScholarshipIdsList(self):
scholarshipIdsList = []
for row in self.rows:
scholarshipIdsList.append(row.PotentialScholarshipId)
return scholarshipIdsList
def insertResultsIntoDB(self):
for prediction, potentialScholarshipId in zip(self.predictedClassStatuses, self.potentialScholarshipIdsList):
prediction = ', '.join(prediction)
self.db.insertUpdateOrDeleteDB(
"update dbo.ClassifiedPotentialScholarships set ClassStatusPrediction='" + prediction + "' where PotentialScholarshipId='" + str(
potentialScholarshipId) + "'")
示例12: getPredictedTagsInsertIntoDatabase
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def getPredictedTagsInsertIntoDatabase():
keywordsList = PivotLeadsGetDatabaseInfo.getKeywords()
for keyword in keywordsList:
keyword = CleanText.cleanALLtheText(keyword)
titleAbstractList = PivotLeadsGetDatabaseInfo(keyword).getTitleAbstractList()
predictedTags = ClassifyFundingTypeKeywordBased(titleAbstractList).returnPredictedTags()
listPivotLeadIds = PivotLeadsGetDatabaseInfo(keyword).getPivotLeadId()
db = SUDBConnect()
for i in range(len(predictedTags)):
tag = predictedTags[i]
pivotLeadId = listPivotLeadIds[i]
db.insertUpdateOrDeleteDB(
"update dbo.PivotLeads set Tag='" + tag + "' where PivotLeadId='" + pivotLeadId + "'")
示例13: getPredictedTagsInsertIntoDatabase
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
def getPredictedTagsInsertIntoDatabase():
keywordsList = GrantForwardItemsGetDatabaseInfo.getKeywords()
db = SUDBConnect()
for keyword in keywordsList:
keyword = CleanText.cleanALLtheText(keyword)
titleDescriptionList = GrantForwardItemsGetDatabaseInfo(keyword=keyword).getTitleDescriptionList()
predictedTags = ClassifyFundingTypeKeywordBased(titleDescriptionList).returnPredictedTags()
listGrantForwardItemIds = GrantForwardItemsGetDatabaseInfo(keyword=keyword).getGrantForwardItemIds()
for i in range(len(predictedTags)):
tag = predictedTags[i]
grantForwardItemId = listGrantForwardItemIds[i]
db.insertUpdateOrDeleteDB(
"update dbo.GrantForwardItems set Tag='" + tag + "' where GrantForwardItemId='" + grantForwardItemId + "'")
示例14: InsertCheggLeadArrayIntoCheggLeadsDB
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class InsertCheggLeadArrayIntoCheggLeadsDB(object):
def __init__(self, cheggLeadArray, fundingClassification, badScholarshipClassification):
self.cheggLeadArray = cheggLeadArray
self.fundingClassification = fundingClassification
self.badScholarshipClassificaion = badScholarshipClassification
self.db = SUDBConnect()
self.fileSystemDB = SUDBConnect(destination='filesystem')
self.name = self.cheggLeadArray[0]
self.url = self.cheggLeadArray[1]
self.deadline = self.cheggLeadArray[2]
self.amount = self.cheggLeadArray[3]
self.eligibility = self.cheggLeadArray[4]
self.applicationOverview = self.cheggLeadArray[5]
self.description = self.cheggLeadArray[6]
self.sponsor = self.cheggLeadArray[7]
self.sourceWebsite = self.cheggLeadArray[8]
self.sourceText = self.cheggLeadArray[9]
self.date = time.strftime('%Y%m%d')
def writeFileToDisk(self):
tableName = 'CheggLeads'
user = 'Kya'
website = re.sub('Leads', '', tableName)
columns = self.db.getColumnNamesFromTable(tableName)
currentRow = self.db.getRowsDB(
"select * from dbo.CheggLeads where Name='" + self.name + "' and Url='" + self.url + "'")[0]
self.fileSystemDB.writeFile(columns, currentRow, user, website, self.url, self.date)
def checkIfAlreadyInDatabase(self):
matchingRow = self.db.getRowsDB(
"select * from dbo.CheggLeads where Name='" + self.name + "' and Url='" + self.url + "'")
if matchingRow != []:
return True
else:
return False
def insertUpdateLead(self):
if not self.checkIfAlreadyInDatabase():
self.db.insertUpdateOrDeleteDB(
"insert into dbo.CheggLeads (Name, Url, Deadline, Amount, Eligibility, ApplicationOverview, Description, Sponsor, SourceWebsite, SourceText, Date, Tag, BadScholarship) values (N'" + self.name + "', N'" + self.url + "', N'" + self.deadline + "', N'" + self.amount + "', N'" + self.eligibility + "', N'" + self.applicationOverview + "', N'" + self.description + "', N'" + self.sponsor + "', N'" + self.sourceWebsite + "', N'" + self.sourceText + "', '" + self.date + "', '" + self.fundingClassification + "', '" + self.badScholarshipClassificaion + "')")
self.writeFileToDisk()
return True
else:
self.db.insertUpdateOrDeleteDB(
"update dbo.CheggLeads set Deadline=N'" + self.deadline + "', Amount=N'" + self.amount + "', Eligibility=N'" + self.eligibility + "', ApplicationOverview=N'" + self.applicationOverview + "', Description=N'" + self.description + "', Sponsor=N'" + self.sponsor + "', SourceWebsite=N'" + self.sourceWebsite + "', SourceText=N'" + self.sourceText + "', Date='" + self.date + "', Tag='" + self.fundingClassification + "', BadScholarship='" + self.badScholarshipClassificaion + "' where Name='" + self.name + "' and Url='" + self.url + "'")
self.writeFileToDisk()
return False
示例15: GoogleLeadsUpdateEmptyLinkBody
# 需要导入模块: from Classes.SUDBConnect import SUDBConnect [as 别名]
# 或者: from Classes.SUDBConnect.SUDBConnect import insertUpdateOrDeleteDB [as 别名]
class GoogleLeadsUpdateEmptyLinkBody(object):
def __init__(self):
self.db = SUDBConnect()
self.listOfEmptyLinkBodyLinks = []
rowsWithEmptyLinkBody = self.db.getRowsDB("select * from dbo.GoogleLeads where ISNULL(LinkBody, '') = ''")
if len(rowsWithEmptyLinkBody) >= 1:
for row in rowsWithEmptyLinkBody:
self.listOfEmptyLinkBodyLinks.append(row.Link)
if len(self.listOfEmptyLinkBodyLinks) >= 1:
for link in self.listOfEmptyLinkBodyLinks:
linkbody = RipPage.getPageSource(link)
linkbody = CleanText.cleanALLtheText(linkbody)
self.db.insertUpdateOrDeleteDB(
"update dbo.GoogleLeads set LinkBody='" + linkbody + "', DateBodyGenerated=GETDATE() where Link='" + link + "'")