Skip to content

Commit

Permalink
Merge pull request #234 from dimagi/nh/err_msg_row_size
Browse files Browse the repository at this point in the history
Provide a helpful error message on "Row size too large"
  • Loading branch information
kaapstorm authored Feb 15, 2024
2 parents 6f7a0c8 + 531df4b commit 803ec6d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion commcare_export/env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import hashlib
import json
import logging
import operator
import sys
import uuid
from typing import Any, Dict, Union, overload

Expand All @@ -12,6 +14,8 @@
from jsonpath_ng import jsonpath
from jsonpath_ng.parser import parse as parse_jsonpath

logger = logging.getLogger(__name__)

JSONPATH_CACHE = {}


Expand Down Expand Up @@ -590,7 +594,23 @@ def lookup(self, key):
def emit_table(self, table_spec):
self.emitted = True
table_spec.rows = self._unwrap_row_vals(table_spec.rows)
self.writer.write_table(table_spec)
try:
self.writer.write_table(table_spec)
except Exception as err:
if (
not logger.isEnabledFor(logging.DEBUG) # not --verbose
and 'Row size too large' in str(err)
):
logging.error(
'Row size too large. The amount of data required by rows '
'is more than this type of database table allows. One '
'way to resolve this error is to reduce the number of '
'columns that you are exporting. A general guideline is '
'not to exceed 200 columns.'
)
sys.exit(1)
else:
raise

def has_emitted_tables(self):
return self.emitted
Expand Down

0 comments on commit 803ec6d

Please sign in to comment.