(self)
| 83 | await self.con.execute('DROP TABLE public.copytab') |
| 84 | |
| 85 | async def test_copy_from_table_large_rows(self): |
| 86 | await self.con.execute(''' |
| 87 | CREATE TABLE copytab(a text, b text); |
| 88 | INSERT INTO copytab (a, b) ( |
| 89 | SELECT |
| 90 | repeat('a' || i::text, 500000), |
| 91 | repeat('b' || i::text, 500000) |
| 92 | FROM |
| 93 | generate_series(1, 5) AS i |
| 94 | ); |
| 95 | ''') |
| 96 | |
| 97 | try: |
| 98 | f = io.BytesIO() |
| 99 | |
| 100 | # Basic functionality. |
| 101 | res = await self.con.copy_from_table('copytab', output=f) |
| 102 | |
| 103 | self.assertEqual(res, 'COPY 5') |
| 104 | |
| 105 | output = f.getvalue().decode().split('\n') |
| 106 | self.assertEqual( |
| 107 | output, |
| 108 | [ |
| 109 | 'a1' * 500000 + '\t' + 'b1' * 500000, |
| 110 | 'a2' * 500000 + '\t' + 'b2' * 500000, |
| 111 | 'a3' * 500000 + '\t' + 'b3' * 500000, |
| 112 | 'a4' * 500000 + '\t' + 'b4' * 500000, |
| 113 | 'a5' * 500000 + '\t' + 'b5' * 500000, |
| 114 | '' |
| 115 | ] |
| 116 | ) |
| 117 | finally: |
| 118 | await self.con.execute('DROP TABLE public.copytab') |
| 119 | |
| 120 | async def test_copy_from_query_basics(self): |
| 121 | f = io.BytesIO() |
nothing calls this directly
no test coverage detected