Skip to content

Commit 053cd20

Browse files
committed
Fully quote table name in copy_from
1 parent aa2663a commit 053cd20

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

postgres_copy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def copy_from(source, dest, engine, **flags):
5050
:param dest: SQLAlchemy model or table
5151
:param engine: SQLAlchemy engine
5252
"""
53-
name = dest.__table__.fullname if is_model(dest) else dest.fullname
53+
tbl = dest.__table__ if is_model(dest) else dest
5454
conn = engine.raw_connection()
5555
cursor = conn.cursor()
5656
formatted_flags = '({})'.format(format_flags(flags)) if flags else ''
57-
copy = 'COPY {} FROM STDOUT {}'.format(name, formatted_flags)
57+
copy = 'COPY "{}"."{}" FROM STDIN {}'.format(tbl.schema, tbl.name, formatted_flags)
5858
cursor.copy_expert(copy, source)
5959
conn.commit()
6060
conn.close()

0 commit comments

Comments
 (0)