in

How can I display my Microsoft SQL Server database into a flask table


Is there anyway to display a sql server database using pyodc and flask while using render template? If so can someone please help me by explaining and posting the code!

PYTHON

### Imported Libraries 
from flask import Flask, redirect, url_for, render_template
import pyodbc 

### Sql Server Connection
conn = pyodbc.connect('Driver={SQL Server};'
                      'Server=PrivateServer;'
                      'Database=REPLICATED_STORAGE;'
                      'Trusted_Connection=yes;')


### Online Flask Server
app = Flask(__name__)
@app.route('/')
def home():
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM FRUITS")
    return render_template("index.html")


if (__name__ == '__main__'):
    app.run()

HTML

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Python Flask Template</title>
        <meta name="viewport" content="width=device-width,initial-scale=1">
    </head>
    <body>
    </p>Hello world</p>
    </body>
</html>



Source: https://stackoverflow.com/questions/70559114/how-can-i-display-my-microsoft-sql-server-database-into-a-flask-table

MySQL: How to Get the Length of Text In A Column

A Bed and Breakfast dApp run on Ethereum. Includes a token + schedule system (Solidity) and full front-end (React + ethers.js) built with Hardhat