添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
犯傻的麻辣香锅  ·  爱师大i-Star·  1 月前    · 
大气的稀饭  ·  PHP laravel docker - ...·  2 月前    · 
拉风的小熊猫  ·  Django ...·  4 月前    · 
跑龙套的黄瓜  ·  Functions for ...·  5 月前    · 

This is what my connection code looks like right now.

connection = pymysql.connect(host='sullberg31.mysql.pythonanywhere-services.com',
                             user='sullberg31',
                             password='{}',
                             db='sullberg31${}',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)

Is there a specific port i should be passing in?

[edit by admin: formatting]

@app.route('/connect/', methods=['POST'])
def testConnect():
    test = request.get_json()
    sshtunnel.SSH_TIMEOUT = 5.0
    sshtunnel.TUNNEL_TIMEOUT = 5.0
    with sshtunnel.SSHTunnelForwarder(
        ('ssh.pythonanywhere.com'),
        ssh_username='sullberg31', ssh_password='{login password}',
        remote_bind_address=('sullberg31.mysql.pythonanywhere-services.com', 3306)
        ) as tunnel:
        connection = mysql.connector.connect(
        user='sullberg31', password='{sql password}',
        host='127.0.0.1', port=tunnel.local_bind_port,
        database='sullberg31${database name}',)
connection.close()
return test

I'm trying to use this code as a simple test to determine whether or not I can connect to my database (and eventually edit it) through an http post request from my local machine. However, every time I run the request I get a json decoder error which makes no sense. Is there a better way to edit my database through http requests?

Traceback (most recent call last):
  File "C:/Users/Seaton/Documents/PythonProjects/Fishing/apiTest.py", line 17, in <module>
    doit = requests.post(url, json=data).json()
  File "C:\Users\Seaton\Anaconda3\lib\site-packages\requests\models.py", line 850, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\Seaton\Anaconda3\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Seaton\Anaconda3\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Seaton\Anaconda3\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

[edit by admin: formatting]

Sorry, we have had to rate-limit your feedback sending.
Please try again in a few moments... Thanks for the feedback! Our tireless devs will get back to you soon.