Python Forum
Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? (/thread-25165.html)

Pages: 1 2 3


RE: Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? - BrandonKastning - Mar-23-2020

(Mar-22-2020, 11:29 AM)ndc85430 Wrote: Sigh. Is there a reason you aren't calling get_text on your variables on line 49 now, exactly like you're doing on line 27?

Yes, the variables declared on lines 9-11 are all global. You should declare your function to take parameters, like you had done in post 5 and then pass the values in. You can find much information on the internet about why using globals is bad.

Ah, you're handling the exception. I wasn't reading the code properly, so disregard my comment about the traceback. If you're interested, the standard library traceback module is useful when you want to print tracebacks during exception handling.

ndc85430,

Would calling get_text on line 49 resolve the error? I am feeling as if the .py currently properly connects to my MariaDB database; however for some reason I do not understand as to why I am having so much difficulties understanding how to pass the variables off correctly.

Thank you for the traceback library information.


RE: Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? - ndc85430 - Mar-23-2020

Why don't you try it? Also, more importantly: is the text the thing you want to store, or not?