-   Notifications  You must be signed in to change notification settings 
- Fork 435
Closed
Description
- asyncpg version: 0.20.1
- PostgreSQL version: 12.2
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
 the issue with a local PostgreSQL install?: I use local PostgreSQL
- Python version: 3.8.3rc1
- Platform: Linux billing 5.4.0-4-cloud-amd64 Other examples? #1 SMP Debian 5.4.19-1 (2020-02-13) x86_64 GNU/Linux
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?:
- Can the issue be reproduced under both asyncio and uvloop?: Yes
Steps to reproduce:
- Create CSV file "copy_test.csv":
echo "Hello,World" > copy_test.csv- This script creates table "copy_test" with two columns and tries to import file by passing file path to conn.copy_to_table():
import asyncio import asyncpg async def main(): conn = await asyncpg.connect(...) await conn.execute("create table copy_test (c1 varchar, c2 varchar)") await conn.copy_to_table( 'copy_test', source='copy_test.csv', format='csv' ) #import uvloop #asyncio.set_event_loop(uvloop.new_event_loop()) asyncio.run(main())Script throws exception:
$ python3 test_asyncpg_copy_to_table.py Traceback (most recent call last): File "test_asyncpg_copy_to_table.py", line 18, in <module> asyncio.run(main()) File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "test_asyncpg_copy_to_table.py", line 8, in main await conn.copy_to_table( File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 666, in copy_to_table return await self._copy_in(copy_stmt, source, timeout) File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 845, in _copy_in return await self._protocol.copy_in( File "asyncpg/protocol/protocol.pyx", line 482, in copy_in File "asyncpg/protocol/protocol.pyx", line 455, in asyncpg.protocol.protocol.BaseProtocol.copy_in File "asyncpg/protocol/protocol.pyx", line 456, in asyncpg.protocol.protocol.BaseProtocol.copy_in File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for return await fut File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 836, in __anext__ data = await run_in_executor(None, f.read, 524288) File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) io.UnsupportedOperation: read And the file "copy_test.csv" is now 0 bytes.
Metadata
Metadata
Assignees
Labels
No labels