M1-Arborator-NaijaSUD/arborator/lib/database.py
def enter(self, cursor, table, columns, values, computeId=True):
		"""
		general function to add data into the database
		"""
		#open("logger.txt","a").write("enter "+str(columns)+"\n")
		#print "INSERT OR IGNORE INTO "+table+" (" + ",".join(columns)+ ") VALUES (" + ",".join(len(values)*"?")+ ") ;"
		#print values
		cursor.execute("INSERT OR IGNORE INTO "+table+" (" + ",".join(columns)+ ") VALUES (" + ",".join(len(values)*"?")+ ") ;", values)
		if computeId:
			cursor.execute("select rowid from "+table+"  where "+ " and ".join( [c+"=?" for c in  columns ] ) + ";",values)
			id=cursor.fetchone()
			if id:
				id,=id
				return int(id)
			else:
				return None
			
			
		else: return None

		general function to add data into the database
		
general function to add data into the database
general function to add data into the database
def enter(self, cursor, table, columns, values, computeId=True):
		cursor.execute("INSERT OR IGNORE INTO "+table+" (" + ",".join(columns)+ ") VALUES (" + ",".join(len(values)*"?")+ ") ;", values)
		if computeId:
			cursor.execute("select rowid from "+table+"  where "+ " and ".join( [c+"=?" for c in  columns ] ) + ";",values)
			id=cursor.fetchone()
			if id:
				id,=id
				return int(id)
			else:
				return None
		else: return None
def enter ( self , cursor , table , columns , values , computeId = True ) : cursor . execute ( "INSERT OR IGNORE INTO " + table + " (" + "," . join ( columns ) + ") VALUES (" + "," . join ( len ( values ) * "?" ) + ") ;" , values ) if computeId : cursor . execute ( "select rowid from " + table + "  where " + " and " . join ( [ c + "=?" for c in columns ] ) + ";" , values ) id = cursor . fetchone ( ) if id : id , = id return int ( id ) else : return None else : return None
general function to add data into the database
general function to add data into the database
"""
		general function to add data into the database
		""" #open("logger.txt","a").write("enter "+str(columns)+"\n") #print "INSERT OR IGNORE INTO "+table+" (" + ",".join(columns)+ ") VALUES (" + ",".join(len(values)*"?")+ ") ;" #print values
self
cursor
table
columns
values
computeId