-
Notifications
You must be signed in to change notification settings - Fork 419
Add support for COPY IN #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
object mview | ||
Py_buffer *pybuf | ||
|
||
mview = PyMemoryView_GetContiguous(data, cpython.PyBUF_SIMPLE, b'C') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to close mview
after you use it?
asyncpg/protocol/protocol.pyx
Outdated
raise RuntimeError( | ||
'no encoder for OID {}'.format(codec.oid)) | ||
|
||
while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this block can be simplified if we remove while True
.
asyncpg/protocol/protocol.pyx
Outdated
break | ||
|
||
elif reader is not None: | ||
iterator = reader.__aiter__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try:
aiter = reader.__aiter__
except AttributeError:
raise TypeError('reader is not an asynchronous iterator')
else:
iterator = aiter()
asyncpg/protocol/protocol.pyx
Outdated
except asyncio.TimeoutError: | ||
self._write_copy_fail_msg('TimeoutError') | ||
self._on_timeout(self.waiter) | ||
await waiter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of await waiter
do this:
try:
await waiter
except TimeoutError:
raise
else:
raise RuntimeError('TimoutError was not raised')
asyncpg/protocol/protocol.pyx
Outdated
'invalid result waiter state on cancellation')) | ||
else: | ||
self.cancel_waiter.set_result(None) | ||
self.cancel_waiter.set_result(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intentionally remove that code? If so the comment above it needs to be adjusted.
raise RuntimeError('failure in source') | ||
|
||
with self.assertRaisesRegexp(RuntimeError, 'failure in source'): | ||
await self.con.copy_to_table('copytab', source=_Source()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add self.assertEqual(await self.con.fetchval('select 1'), 1)
to all tests that test failures to make sure that the protocol is fully recovered?
b310291
to
445775c
Compare
This commit adds two new Connection methods: copy_to_table() and
copy_records_to_table() that allow copying data to the specified
table either in text or, in the latter case, record form.
Related-To #123.
Closes #21.