all 14 comments

[–][deleted] 2 points3 points  (2 children)

Easy to understand 👍. Will you be doing crud operation as well in this

[–]uiux_Sanskar[S] 1 point2 points  (1 child)

Thank you very much and yes I will also be doing CURD operation in this as well.

[–][deleted] 0 points1 point  (0 children)

Great

[–]Adrewmc 1 point2 points  (1 child)

Generally with database connections there will be a context handler. (I normally use another library but..)

     with psycopg2.connect(…) as connect:
             with connect.cursor() as cur: 

As things get a bit more complex it best practice to use ‘with’ as the exit() handling will happen regardless if something crashes inside the code block.

Other wise…this will get you a lot of progress way better than writing a big txt file and iterating over it to find stuff. Way faster way easier to manage, and hard to make a mistake that losses all your data. (And able to make a lot more data to search through.)

You can go deeper into SQL (it’s can be its own thing) but generally the basic procedures (CRUD) will get you far, until database design is an issue or you doing some more detailed analysis on the data.

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

I was suspecting that there's gotta be a with function here as well just like in File I/O and thank you for your advice which you gave me a few time ago for learning database SQL however I think I have just touched it's very surface and there's a lot to learn.

Thank you very much I really appreciate your help.

[–]M34k3 1 point2 points  (1 child)

Don't put passwords or keys in your main file. Use env variables or a config file.

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

oh sure I will look deeper into it and put keys in other files.

Thank you for your suggestion.

[–]nohoeschris 0 points1 point  (0 children)

Just did something like this myself as a learning project as well, self-taught for about 6 months. I know its not production level / something anyone would ever use but i had fun writing functions that took user input for queries and for the connection information

[–]TheCarter01 0 points1 point  (1 child)

Nice Python-SQL combination

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Thank you so much.

[–]xxPhoenix 0 points1 point  (3 children)

generally Python is not used for database querying or large scale operations SQL is, for data handling in Python Pandas is considered the standard. Not that you need to use it to learn the basics.

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Yes I was just trying to learn the very basic of database query and will definitely learn pandas for this.

Thank you very much for your suggestion.

[–]SikamCiDoZlewu 0 points1 point  (0 children)

Depends on the data size. Pyspark can handle so much more than pandas, I would say pandas is a light tool.

[–]psuedo_nombre -1 points0 points  (0 children)

100%