Multiple pages app connect to same sql database


How to connect to the same sql database for multiple pages app in

Currently, I attached the connection code to every single page. :joy:

Hello @beginof,

You can either do that or create a utils function that returns the connection and import it into each of the pages.

can you share the sample code?



import pyodbc

conn = pyodbc.connect(your connection)


from utils/conn import conn

You can get fancier and return different things with a function, and so forth, especially if you have multiple databases. :grin:

1 Like

Thanks @jinnyzor :grinning: