Exemple #1
0
def register(args):
    profile_pic = base64photo(args['Photo'])
    my_cursor = db.cursor()
    my_cursor.execute("SELECT AadharNo from User WHERE AadharNo = '" +
                      str(args['AadharNo']) + "'")
    row_cursor = my_cursor.fetchall()
    if len(row_cursor) > 0:
        return {
            'Status':
            0,
            'Message':
            'Account already exist for this aadhaar no :' +
            str(args['AadharNo'])
        }
    else:
        if len(str(args['Phoneno'])) == 10 and len(str(
                args['AadharNo'])) == 12:
            current_time = datetime.datetime.now()
            sql = "INSERT INTO User (Name,Phoneno,AadharNo,Latitude,Longitude,ProfilePic,OnDate) VALUES " \
                  "(%s,%s,%s,%s,%s,%s,%s)"
            val = (args['Name'], args['Phoneno'], args['AadharNo'],
                   args['Latitude'], args['Longitude'], profile_pic,
                   current_time)
            my_cursor.execute(sql, val)
            db.commit()
            user_id = my_cursor.lastrowid
            db.close()
            return {
                'Message': 'Registered Successfully',
                'UserID': user_id,
                'Status': 1
            }
        else:
            return {'Message': 'Please enter valid data', 'Status': 0}
Exemple #2
0
def location_update(args):
    my_cursor = db.cursor()
    current_time = datetime.datetime.now()
    sql = "INSERT INTO Location (UserID,Latitude,Longitude,OnDate) VALUES (%s,%s,%s,%s)"
    val = (args['userid'], args['latitude'], args['longitude'], current_time)
    my_cursor.execute(sql, val)
    db.commit()
    return {'Message': 'Success', 'Status': 1}
Exemple #3
0
	def getFetchedUrls(self):
		'''Get fetched URLs.'''
		cur = db.cursor()
		cur.execute('select url from fetched_urls where fid = %s' % self.fid)
		result = cur.fetchall()
		cur.close()
		urlList = [item[0] for item in result]
		# print '-----The fetched URLs is', urlList
		return urlList
Exemple #4
0
	def updateDb(self):
		'''Update status in database for the crawling of this time.'''
		cur = db.cursor()
		if len(self.subList) > 0:
			sql = '''update subscription set last_push = '%s' where sid in (%s)''' \
			% (self.dateTime.strftime("%Y-%m-%d %H:%M:%S"), ','.join(str(i) for i in self.subList))
			cur.execute(sql)
		if len(self.fetchedUrlList) > 0:
			cur.execute("delete from fetched_urls where fid = %s and datediff(%s, fetch_time) >= 2",
				(self.fid, self.dateTime.strftime("%Y-%m-%d %H:%M:%S")))
			cur.executemany('''insert into fetched_urls (fid, url, title, fetch_time)
				values (%s, %s, %s, %s)''', self.fetchedUrlList)
		cur.close()
Exemple #5
0
def getFeedList():
	cur = db.cursor()
	feedList = []
	cur.execute('''select fid, name, spider_name, base_url
		from feeds''')
	for item in cur.fetchall():
		feed = {'fid': item[0],
				'name': item[1],
				'spiderName': item[2],
				'baseUrl': item[3]
		}
		feedList.append(feed)
	cur.close()
	return feedList
Exemple #6
0
def login(aadhar):
    my_cursor = db.cursor()
    my_cursor.execute("SELECT AadharNo from User WHERE AadharNo = '" +
                      str(aadhar) + "'")
    row_cursor = my_cursor.fetchall()
    if len(str(aadhar)) == 12:
        if len(row_cursor) > 0:
            return {
                'Message': 'Congratulation login successfully',
                'Status': 1
            }
        else:
            return {'Message': 'Sorry Wrong Credentials', 'Status': 0}
    else:
        return {'Message': 'Please enter valid data', 'Status': 0}
Exemple #7
0
	def getSubObjList(self):
		'''Get the subscriber list of this feed.'''
		cur = db.cursor()
		sqlQuery = '''select sb.sid, sb.name, sb.email, sp.max_received
		from subscription sp, subscribers sb
		where sp.fid = %s and sp.sid = sb.sid
		and sb.status = 1
		and time_to_sec(timediff('%s' , sp.last_push))/60 >= sp.frequence
		and sb.push_start <= %s
		and sb.push_end >= %s'''
		# print sqlQuery % (self.fid, self.dateTime.strftime("%Y-%m-%d %H:%M:%S"), self.dateTime.hour, self.dateTime.hour)
		subObjDict = {}
		cur.execute(sqlQuery % (self.fid, self.dateTime.strftime("%Y-%m-%d %H:%M:%S"),
			self.dateTime.hour, self.dateTime.hour))
		for item in cur.fetchall():
			subInfo = {'name': item[1],
					   'email': item[2],
					   'max_received': item[3]
			}
			subObjDict[item[0]] = Subscriber(subInfo)
		cur.close()
		return subObjDict