Python Forum
Help with Python technologies and structure code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Python technologies and structure code
#1
Hello everybody,

I am new to Pyhton and already appreciating its power. I am building a little desktop app and i need somesuggestions, i hope this will help me to learn a lot.

I have some data in a database and i simply need to read the data and write it in a an Excel file. I also need to, depending on the data output, send email notification with plots. This is all. At some point i will have a scheduling to automatically start the script, but for now i need to make a simple GUI as well.

At the moment i am using the follwoing technologies, i hope you can tell me if there is something better:

- Using Python 2.7. What's the biggest difference with python 3?

- Tkinter: i am using Tkinter for the GUI, however i saw that lately PyQt is getting really famous. Which is better?

- MySql Python connector: here is my bigger doubt. I am reading data by directly accessing the database.
However, i read that is best to use a Query builder or an ORM for this purpose. I read that Django is a very
famous ORM for Python but i can see it is mostly used for back-end website programming. Would be possible
to use it for this purpose as well or itjust fits website projects? How do you then suggest to structure the
code? there should be a neat division between DjangoCode, GUI and app?

- Openpyxl: i find this tool very easy to write to Excel files.

- Email and plots: Haven't looked into it yet, but i was reaing about Plotly for plots. I havent looked for
a library for sending e-mails yet

Here it is all my doubts, i would really appreciate some help. I am new to Python and willing to learn and i think this project could be a good start-off.

Thanks
Reply
#2
(Aug-11-2018, 06:40 PM)giu88 Wrote: Using Python 2.7. What's the biggest difference with python 3?

Use python3, python2 support ends January 1st, 2020

(Aug-11-2018, 06:40 PM)giu88 Wrote: MySql Python connector: here is my bigger doubt. I am reading data by directly accessing the database.

MySQL connector is fine.

You may also want to explore SQLAlchemy
https://www.eversql.com/django-vs-sqlalc...is-better/
https://engineering.betterworks.com/2015...nd-django/

Main disadvantage with using MySQL connector is that it will require more efforts to migrate to different DB if need arise in the future. With SQLAlchemy it will be easy to do it.

(Aug-11-2018, 06:40 PM)giu88 Wrote: Tkinter: i am using Tkinter for the GUI, however i saw that lately PyQt is getting really famous. Which is better?
Tkinter is OK for start, but Qt will give much more appealing look. Apart from PyQT there is also PySide. With PyQt you need to pay for commercial licenses if you will sell your application. There is also other very nice alternatives like wxPython and PyGTK.

for notifications - you can implement it yourself. But may also look at third party packages like notifiers
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks a lot that helped!!
Reply
#4
(Aug-11-2018, 07:09 PM)buran Wrote: different DB
different as in 'PostgreSQL instead of MySQL'
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Thanks. What about how to structure the code? Would be a good practice to completely separate DB code(SQL Alchemy calls), GUI and script itself? Maybe with interfaces? I have some experience with c++ but i wouldn't know how to do this with python.

Thanks
Reply
#6
definitely separate at least gui and rest of the code. i.e. you can develop non-gui part separately as pure CLI application.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Perfect, thanks for helping! I gave you +1 reputation, i hope this is the best way to thank you
for your help. Sorry, i am new in the forum.
Reply
#8
I'm sure others would share their views too
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
Ok, i'll be waiting for more suggestions then. Thanks again
Reply
#10
(Aug-11-2018, 07:55 PM)giu88 Wrote: Thanks. What about how to structure the code? Would be a good practice to completely separate DB code(SQL Alchemy calls), GUI and script itself? Maybe with interfaces?
I have moved more away from GUI(WxPython user) and doing most with web-app(Replace GUI and can have more modern look) mostly in Flask.
DB is a more normal part of a web-app than it is with GUI.
Flask-SQLAlchemy is very elegant,even more so than Django DB connection.
Have freedom to connect to any DB with Flask-SQLAlchemy.

Structure of code have more freedom in Flask than Django,
but it will mostly be same in lager application.
So have eg models.py(DB) and views.py(render the HTML content of the page) ect...
Can eg look at Weather app for basic usage with Flask.

giu88 Wrote:- Openpyxl: i find this tool very easy to write to Excel files.
Also look into Pandas and Jupyter Notebook,
this combo can replace Excel all together.
Common Excel Tasks Demonstrated in Pandas
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020