Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 源代码提示数据已保存,但表中未显示任何数据。使用pyCharm和Postgres进行开发_Python_Postgresql_Pycharm - Fatal编程技术网

Python 源代码提示数据已保存,但表中未显示任何数据。使用pyCharm和Postgres进行开发

Python 源代码提示数据已保存,但表中未显示任何数据。使用pyCharm和Postgres进行开发,python,postgresql,pycharm,Python,Postgresql,Pycharm,我有一个源代码,它保存了我开发的网页中的一组数据/输入。网页提示数据已保存,但查看表时,未保存任何记录。我正在使用pyCharm和Postgres进行此开发。希望有人能帮我 顺便说一下,我使用一个存储过程将数据集保存到表中,当我通过Postgres执行它时,这个存储过程非常好 - 我在编辑我的问题时添加了源代码。以下是与我的问题相关的所有源代码: from DBHelper import DBHelper class Manufacturer: def saveManufacturer

我有一个源代码,它保存了我开发的网页中的一组数据/输入。网页提示数据已保存,但查看表时,未保存任何记录。我正在使用pyCharm和Postgres进行此开发。希望有人能帮我

顺便说一下,我使用一个存储过程将数据集保存到表中,当我通过Postgres执行它时,这个存储过程非常好

- 我在编辑我的问题时添加了源代码。以下是与我的问题相关的所有源代码:

from DBHelper import DBHelper

class Manufacturer:
    def saveManufacturer(self, request):
        from django.db import connection, transaction
        helper = DBHelper()
        try:
            sql = format("SELECT savemanufacturer('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (request.POST["manuCode"],
                         request.POST["longDesc"],
                         request.POST["shortDesc"],
                         request.POST["manuFlag"],
                         request.POST["activityStat"],
                         request.POST["activityDate"],
                         request.POST["street1"],
                         request.POST["street2"],
                         request.POST["city"],
                         request.POST["contactPerson1"],
                         request.POST["position1"],
                         request.POST["phone1"],
                         request.POST["contactPerson2"],
                         request.POST["position2"],
                         request.POST["phone2"],
                         request.POST["fax"],
                         request.POST["tin"]
            ))

            cursor = connection.cursor()
            cursor.execute(sql)

            result = cursor.fetchall()
        except Exception,e:
            print(e)

        return result[0]
--- 我添加了我的存储过程。希望这有助于发现问题。我非常感谢您的帮助:

        CREATE OR REPLACE FUNCTION savemanufacturer(mancode text, longdesc text, shortdesc text, manuflag text, actstat text, actdate text, st1 text, st2 text, city text, person1 text, position1 text, person2 text, postion2 text, phone1 text, phone2 text, fax text, tin text)
          RETURNS integer AS
        $BODY$
        DECLARE myActDate TIMESTAMP;

        BEGIN
        myActDate := to_timestamp(ActDate,'YYYY-MM-DD');
        INSERT INTO "DEDGE_master_files_tblvendor"("VendorCode",
                               "LongDesc",
                               "ShortDesc",
                               "ManuFlag",
                               "ActivityStat",
                               "ActivityDate",
                               "Street1",
                               "Street2",
                               "City",
                               "ContactPerson1",
                               "Position1",    
                               "Phone1",
                               "ContactPerson2",
                               "Position2",
                               "Phone2",
                               "Fax",
                               "TIN")

        VALUES(ManCode,
               LongDesc,
               ShortDesc,
               ManuFlag,
               ActStat,
               myActDate,
               St1,
               St2,
               City,
               Person1,
               Position1,
               Phone1,
               Person2,
               Postion2,
               Phone2,
               Fax,
               TIN);
        RETURN 1;
        END;
        $BODY$
          LANGUAGE plpgsql VOLATILE
--- 最后是javascript,它也与这个问题有关:

        $("#manufacturer-add").click(function(){
            $("#manufacturer-add").fadeOut();
            $("#manufacturer-save").fadeIn();
        });

        $("#manufacturer-save").click(function (){
            var myData = {
                "token":"savemanufacturer",
                "manuCode":$("#ManufacturerCode").val(),
                "longDesc":$("#LongDesc").val(),
                "shortDesc":$("#ShortDesc").val(),
                "manuFlag":$("#ManuFlag").val(),
                "activityStat":$("#ActivityStat").val(),
                "activityDate":$("#ActivityDate").val(),
                "street1":$("#Street1").val(),
                "street2":$("#Street2").val(),
                "city":$("#City").val(),
                "contactPerson1":$("#ContactPerson1").val(),
                "position1":$("#Position1").val(),
                "phone1":$("#Phone1").val(),
                "contactPerson2":$("#ContactPerson2").val(),
                "position2":$("#Position2").val(),
                "phone2":$("#Phone2").val(),
                "fax":$("#Fax").val(),
                "tin":$("#TIN").val()
            }

            var csrftoken = getCookie('csrftoken');
            $.ajaxSetup({
                beforeSend: function (xhr, settings){
                    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
                    }
                }
            });

            $.ajax({
                url: "/DEDGE/AJAX/IM/Maintain/Manufacturer",
                type: "POST",
                data: myData,
                success: function (msg){
                    if (msg==1){
                        alert("Successfully saved manufacturer!");
                    } else{
                        alert("Oops! " + msg)
                    }
                }
            })
        })

你在用比特纳米吗?尝试重新安装独立的postgresql并尝试使用commit

一些代码将有助于深入了解问题。您好,欢迎使用StackOverflow。为了让我们找出代码中的错误,我们需要查看一些代码——否则,我们只是猜测。请参阅,以获取关于包含什么和删除什么的一些提示。我想这不是PyCharm的错,也不是Postgres的错,而是您编写的代码中的一个问题。所以,没有告诉我们关于你的代码的任何信息,这里没有什么可以帮助你的。据我所知,你的代码中没有提交。很抱歉,我对这有点陌生,但我应该将提交放在哪一部分?