| 603 | |
| 604 | |
| 605 | class PGDialect_psycopg2(_PGDialect_common_psycopg): |
| 606 | driver = "psycopg2" |
| 607 | |
| 608 | supports_statement_cache = True |
| 609 | supports_server_side_cursors = True |
| 610 | |
| 611 | default_paramstyle = "pyformat" |
| 612 | # set to true based on psycopg2 version |
| 613 | supports_sane_multi_rowcount = False |
| 614 | execution_ctx_cls = PGExecutionContext_psycopg2 |
| 615 | preparer = PGIdentifierPreparer_psycopg2 |
| 616 | psycopg2_version = (0, 0) |
| 617 | use_insertmanyvalues_wo_returning = True |
| 618 | |
| 619 | returns_native_bytes = False |
| 620 | |
| 621 | _has_native_hstore = True |
| 622 | |
| 623 | colspecs = util.update_copy( |
| 624 | _PGDialect_common_psycopg.colspecs, |
| 625 | { |
| 626 | JSON: _PGJSON, |
| 627 | sqltypes.JSON: _PGJSON, |
| 628 | JSONB: _PGJSONB, |
| 629 | ranges.INT4RANGE: _Psycopg2NumericRange, |
| 630 | ranges.INT8RANGE: _Psycopg2NumericRange, |
| 631 | ranges.NUMRANGE: _Psycopg2NumericRange, |
| 632 | ranges.DATERANGE: _Psycopg2DateRange, |
| 633 | ranges.TSRANGE: _Psycopg2DateTimeRange, |
| 634 | ranges.TSTZRANGE: _Psycopg2DateTimeTZRange, |
| 635 | }, |
| 636 | ) |
| 637 | |
| 638 | def __init__( |
| 639 | self, |
| 640 | executemany_mode="values_only", |
| 641 | executemany_batch_page_size=100, |
| 642 | **kwargs, |
| 643 | ): |
| 644 | _PGDialect_common_psycopg.__init__(self, **kwargs) |
| 645 | |
| 646 | if self._native_inet_types: |
| 647 | raise NotImplementedError( |
| 648 | "The psycopg2 dialect does not implement " |
| 649 | "ipaddress type handling; native_inet_types cannot be set " |
| 650 | "to ``True`` when using this dialect." |
| 651 | ) |
| 652 | |
| 653 | # Parse executemany_mode argument, allowing it to be only one of the |
| 654 | # symbol names |
| 655 | self.executemany_mode = parse_user_argument_for_enum( |
| 656 | executemany_mode, |
| 657 | { |
| 658 | EXECUTEMANY_VALUES: ["values_only"], |
| 659 | EXECUTEMANY_VALUES_PLUS_BATCH: ["values_plus_batch"], |
| 660 | }, |
| 661 | "executemany_mode", |
| 662 | ) |
no outgoing calls