File: psycopg.py

package info (click to toggle)
python-databases 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 312 kB
  • sloc: python: 3,333; makefile: 11
file content (17 lines) | stat: -rw-r--r-- 506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from sqlalchemy.dialects.postgresql.psycopg import PGCompiler_psycopg


class APGCompiler_psycopg2(PGCompiler_psycopg):
    def construct_params(self, *args, **kwargs):
        pd = super().construct_params(*args, **kwargs)

        for column in self.prefetch:
            pd[column.key] = self._exec_default(column.default)

        return pd

    def _exec_default(self, default):
        if default.is_callable:
            return default.arg(self.dialect)
        else:
            return default.arg