python next_pk.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python next_pk.py相关的知识,希望对你有一定的参考价值。

from django.db import connection
from django.utils.deconstruct import deconstructible


@deconstructible
class NextPk:
    def __init__(self, table_name):
        self.table_name = table_name

    def __call__(self):
        with connection.cursor() as cursor:
            cursor.execute("select nextval('{}_id_seq')".format(self.table_name))
            next_id_row = cursor.fetchone()
            return next_id_row[0]

    def __eq__(self, other):
        return self.table_name == other.table_name

以上是关于python next_pk.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python