Samagra-Development / Text2SQL

20 stars 11 forks source link

reuse of get_connection to make code more organised #42

Closed ShubhamBhut closed 12 months ago

ShubhamBhut commented 1 year ago

Since we already have a get_connection() method to connect with databases, it would be better to use it instead of connecting manually for each query execution. This reduces code size and makes it more organised as well as readable

suyashgautam commented 1 year ago

Hey @ShubhamBhut If you look into the functions closely you will realize that we create a dummy database for the schema that the user sends as part of onboarding. Now the idea of using the get_connection is fine in general function like create_database_and_schema but once we have created the database then we want to use it using the schema id which gets generated as part of onboarding so if you look closely other functions have a database key which is being provided to connect to that particular db. I would suggest can you please refactor the code accordingly. Let me know if you have any questions.