Skip to content

Commit

Permalink
Merge branch 'feature/import-csvs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Banin committed Jul 15, 2016
2 parents ed96953 + 3c01349 commit 52595ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dbt/seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from runner import RedshiftTarget
from csvkit import table as csv_table, sql as csv_sql
from sqlalchemy.dialects import postgresql as postgresql_dialect
import psycopg2

class Seeder:
def __init__(self, project):
Expand Down Expand Up @@ -81,7 +82,13 @@ def do_seed(self, schema, cursor, drop_existing):
else:
self.create_table(cursor, schema, table_name, virtual_table)

self.insert_into_table(cursor, schema, table_name, virtual_table)
try:
self.insert_into_table(cursor, schema, table_name, virtual_table)
except psycopg2.ProgrammingError as e:
print('Encountered an error while inserting into table "{}"."{}"'.format(schema, table_name))
print('Check for formatting errors in {}'.format(csv_path))
print('Try --drop-existing to delete and recreate the table instead')
print(e.message)


def seed(self, drop_existing=False):
Expand Down

0 comments on commit 52595ca

Please sign in to comment.