MCPcopy
hub / github.com/HKUDS/AI-Trader / _replace_sqlite_datetime_functions

Function _replace_sqlite_datetime_functions

service/server/database.py:182–190  ·  view source on GitHub ↗
(sql: str)

Source from the content-addressed store, hash-verified

180
181
182def _replace_sqlite_datetime_functions(sql: str) -> str:
183 def replace_interval(match: re.Match[str]) -> str:
184 amount = match.group(1)
185 unit = match.group(2)
186 return f"to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC') + INTERVAL '{amount} {unit}', 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"')"
187
188 sql = _SQLITE_INTERVAL_PATTERN.sub(replace_interval, sql)
189 sql = _SQLITE_NOW_PATTERN.sub(_POSTGRES_NOW_TEXT_SQL, sql)
190 return sql
191
192
193def _adapt_sql_for_postgres(sql: str) -> str:

Callers 1

_adapt_sql_for_postgresFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected