问题
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