]> git.phdru.name Git - sqlconvert.git/blobdiff - sqlconvert/process_mysql.py
Implement is_insert()
[sqlconvert.git] / sqlconvert / process_mysql.py
index 218655aa976090c7af1a79c6881ca6d35b0311e0..9e342c2e04ec7c5ad4ba1796731932320762e5f3 100644 (file)
@@ -1,6 +1,7 @@
 
 from sqlparse.sql import Comment
 from sqlparse import tokens as T
+from .process_tokens import escape_strings, is_comment_or_space
 
 
 def _is_directive_token(token):
@@ -69,7 +70,17 @@ def unescape_strings(token_list):
             token.normalized = token.value = value
 
 
-def process_statement(statement):
-    remove_directive_tokens(statement)
+def is_insert(statement):
+    for token in statement.tokens:
+        if is_comment_or_space(token):
+            continue
+        return (token.ttype is T.DML) and (token.normalized == 'INSERT')
+
+
+def process_statement(statement, quoting_style='sqlite'):
     requote_names(statement)
     unescape_strings(statement)
+    remove_directive_tokens(statement)
+    escape_strings(statement, quoting_style)
+    yield statement
+    return