delete from blabla_1archive_visits where `date`<'2014-01-10';
deletefromblabla_1archive_visitswhere`date`<'2014-01-10';
diff2_s = diff2(str_query[:], BD, queryId)
def diff2(str_query,BD, queryId):
print 'pre diff2\n3 $$$ ' ,str_query, '\n\n\n'
line = 0
cursor.execute('''SELECT id,query FROM queryTable WHERE database = ?''', (BD,))
rows = cursor.fetchall()
for row in rows:
if diff3_ctypes(str_query, row[1]) > 80.:
print 'after diff2\n4 $$$ ' ,str_query, '\n\n\n'
line = row[0]
break
else: continue
if line: return line
else: return False
#include <stdio.h>
#include <string.h>
float diff3 (char str1[],char str2[]) {
char *token1, *last1;
char *token2, *last2;
char *i1[10000];
char *i2[10000];
float summ = 0;
float res = 0;
float j1 = 0, j2 = 0;
float x1,x2;
token1 = strtok_r(str1, " ,=().", &last1);
while (token1 != NULL) {
i1[(int)j1] = token1;
j1 = j1+1;
token1 = strtok_r(NULL, " ,=().", &last1);
}
token2 = strtok_r(str2, " ,=().", &last2);
while (token2 != NULL) {
i2[(int)j2] = token2;
j2=j2+1;
token2 = strtok_r(NULL, " ,=().", &last2);
}
x1 = j1;
x2 = j2;
if (x1<=x2)
{
for (float k = 0.0; k < x1; k = k+1)
{
if (!strcmp(i1[(int)k],i2[(int)k]))
{
summ = summ+1.0;
}
}
res = summ/x1*100.0;
}else{
for (float k = 0.0; k < x2; k = k + 1)
{
if (!strcmp(i1[(int)k],i2[(int)k]))
{
summ = summ + 1.0;
}
}
res = summ/x2*100.0;
}
return res;
}