MCPcopy
hub / github.com/AbdullahGhanem/quran-database / parse_sql_value

Function parse_sql_value

convert_to_sqlite.py:98–119  ·  view source on GitHub ↗

Parse a single SQL value string into Python type.

(v)

Source from the content-addressed store, hash-verified

96
97
98def parse_sql_value(v):
99 """Parse a single SQL value string into Python type."""
100 v = v.strip()
101 if v == 'NULL':
102 return None
103 if (v.startswith("'") and v.endswith("'")) or (v.startswith('"') and v.endswith('"')):
104 s = v[1:-1]
105 s = s.replace("\\'", "'").replace('\\"', '"').replace('\\\\', '\\')
106 s = s.replace('\\n', '\n').replace('\\r', '\r').replace('\\t', '\t')
107 # Handle BOM at start of first value
108 if s.startswith('\ufeff'):
109 s = s[1:]
110 return s
111 try:
112 return int(v)
113 except ValueError:
114 pass
115 try:
116 return float(v)
117 except ValueError:
118 pass
119 return v
120
121
122def parse_insert_row(line, col_names):

Callers 1

parse_insert_rowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected