Write sql file with extracts from MySQL Blob tables
Hi all,
I've got a problem to write sql file with extracts from MySQL Blob tables.
When I want to import the sql file in MySQL I've got some error message:
***********************************************************************************
ERROR 1064 (42000) at line 37: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('536674','0','????\0JFIF\0\0H\0H\0\0??tPhotoshop 3.0\08BIM?\0\0\0\0\0\0H' at line 3
***********************************************************************************
I suppose there is a encodage problem with the string I want to write in my file...
my code :
*********************************************************************************
def normalizetext(texte):
textemodif = texte.replace("'",r"\'")
textemodif = textemodif.replace('"',r'\"')
textemodif = textemodif.replace('\r',r'\r')
textemodif = textemodif.replace('\n',r'\n')
textemodif = textemodif.replace('\0',r'\0')
textemodif = textemodif.replace('\b',r'\b')
textemodif = textemodif.replace('\t',r'\t')
textemodif = textemodif.replace('\v',r'\v')
textemodif = textemodif.replace('\e',r'\e')
return textemodif
for lignes in range(len(result)):
insert = "("
j = 0
for champs in range(len(result[lignes])):
texte = normalizetext(str(result[lignes][champs]))
insert = insert+"'%s'" %texte
if j != len(result[lignes])-1:
insert = insert + ","
j = j+1
insert = insert +")"
swdfile.write(insert)
swdfile.write('\n')
swdfile.close()
*********************************************************************************
Thanks for help
Jean-Pierre
Subject
Written By
Posted
Write sql file with extracts from MySQL Blob tables
May 30, 2008 07:09AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.