Flask + Sqlite3 incorrect formatting

两盒软妹~` 提交于 2021-02-08 10:30:44

问题


I am building a website where people can apply for the team, it's been going well so far however when I display the applications on a page, this shows up.

(' IGN:\r\n Age:\r\n Server Proxy:\r\n Nationality:\r\n TeamSpeak?:\r\n Discord?:\r\n Twitter?:\r\n YouTube?:\r\n Requirement Option:\r\n Exceptions:\r\n Current Clans?:\r\n Why Ominous?:\r\n\t\t\t\t\t\t',)

The textarea looks like this,

                </header>
                    <h1>Enter Application</h1>
                <form action="/memberapp" method="POST">
                    <textarea type="text" name="text" size="350" rows="13">
IGN:
Age:
Server Proxy:
Nationality:
TeamSpeak?:
Discord?:
Twitter?:
YouTube?:
Requirement Option:
Exceptions:
Current Clans?:
Why Ominous?:
                    </textarea>
                    <br>
                    <input type="submit" name="my-form" value="Submit">   

The way I am inserting the data looks like this:

text = request.form['text']
connect()
conn = sqlite3.connect("main.db")
c = conn.cursor()
c.execute("INSERT INTO memberapps VALUES(?)", (text,))
conn.commit()
conn.close()
conn = sqlite3.connect("main.db")

That isn't the issue however, finally, the way I am displaying it is like so:

conn = sqlite3.connect("main.db")
c = conn.cursor()
c.execute("SELECT * FROM memberapps")
r = c.fetchall()
conn.close()
return render_template('member-view.html', rows=r)

{% for r in rows %} <h2>{{r}}</h2> {% endfor %}

Thanks!

来源:https://stackoverflow.com/questions/46779416/flask-sqlite3-incorrect-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!