无法使用flask

问题描述

我在名为“MGSF.xabis.com”的服务器上运行了一个代码代码的主要功能是向db表中插入数据。当我提供同一台服务器的 sql db 表时,它工作正常,但是当我想将数据插入另一台名为“poeh.xabis.com”的服务器的 sql 数据库表时,它抛出以下错误

pypyodbc.DatabaseError: ('08001','[08001] [Microsoft][ODBC sql Server Driver][dbnETLIB]sql Server 不存在或访问被拒绝。')

所以我不知道我们是否可以在将烧瓶应用程序插入另一台服务器的同时将数据插入另一台服务器。

from flask import Flask
from flask import jsonify
import MysqL.connector
import pypyodbc as pyodbc

app = Flask(__name__)

@app.route('/')
def hello():
    print("Just go inside ")
    return 'Atlast got inside Page'

@app.route('/WritetoFile/<filename>')
def WritetoaFile(filename):
    f = open(filename+".txt","a")
    f.write("Now the file has more content!")
    f.close()

    # open and read the file after the appending:
    f = open(filename+".txt","r")

    return  f.read()

@app.route('/insertdataToDBFile/<dbname>')
def writetodbfile(dbname):
    conn = pyodbc.connect('Driver={sql Server};'
                          'Server=poeh.xabis.com;'
                          'Database=Selfheal;'
                          'Trusted_Connection=yes;'
                          'PORT=1433;')
     
    cursor = conn.cursor()
    cursor.execute('''
                INSERT INTO Issue VALUES('Hi;llos','20120618 10:34:09 AM','kl','prod','yes','123','poem')
                ''')
    conn.commit()
    cursor.execute('SELECT * FROM Selfheal.dbo.Issue')
     
    for row in cursor:
        print(row)
    return (str(cursor.rowcount) + " record inserted.")

if __name__ == '__main__':
    app.run(host='127.0.0.1',port=8015,debug=True)

以上代码位于 'MGSF.xabis.com' 并且此数据应插入到当前的 MSsql DB 表中 **"poeh.xabis.com" **

MGSF.xabis.com 和 poeh.xabis.com 是两个远程 windows 服务器

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)