Python Forum
How to select NULL and blank values from MySQL table into csv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to select NULL and blank values from MySQL table into csv
#3
(Dec-19-2022, 07:19 PM)deanhystad Wrote: Wrap code in python tags to save formatting

Python csv.writer will write null as a blank string. Actually, it writes None as a blank string. Database nulls are converted to Python Nones.

Knowing that you cannot write a None (or a null) to a csv file, what do you want to write? Maybe replace all occurrences of None in myresult to the string "null"?

Thank you for your reply. Yes I would try to get something other than blank for DB NULL value. I am not sure what will be best but I think using NaN might be a good idea. I will use these values to load into oracle DB and there also I want to be able to insert DB NULL or blank to match what was in the MySQL DB. Using NaN might help to insert NULL using pandas and numpy.
Reply


Messages In This Thread
RE: How to select NULL and blank values from MySQL table into csv - by python300 - Dec-19-2022, 09:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 858 Oct-03-2023, 10:25 PM
Last Post: lostintime
  How to express null value klatlap 3 1,010 Mar-25-2023, 10:40 AM
Last Post: klatlap
  Replacing values ​​in Mysql with a condition stsxbel 0 712 Mar-05-2023, 08:20 PM
Last Post: stsxbel
  Mysql Workbench table not updated CatBall 2 1,254 Feb-13-2023, 05:37 PM
Last Post: CatBall
  Write Null values as 0.0 (float) type in csv mg24 3 1,639 Dec-07-2022, 09:04 PM
Last Post: deanhystad
  store all variable values into list and insert to sql_summary table mg24 3 1,295 Sep-28-2022, 09:13 AM
Last Post: Larz60+
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,874 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  value null when update in json file 3lnyn0 6 3,772 Dec-30-2021, 05:52 PM
Last Post: ndc85430
  Sum the values in a pandas pivot table specific columns klllmmm 1 4,859 Nov-19-2021, 04:43 PM
Last Post: klllmmm
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,277 Jul-02-2021, 02:19 PM
Last Post: xtc14

Forum Jump:

User Panel Messages

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