Python Forum
Write SQLite query result to file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write SQLite query result to file
#1
I need to write a SQLite query result in a file:

c.execute("SELECT * FROM mytable ORDER BY date(Date) ASC LIMIT 1;")
f.write(c.fetchone())

but I get this error:

TypeError: argument 1 must be string or read-only character buffer, not None

how can I solve this?
Reply
#2
Have a look at these links
https://www.pythonforbeginners.com/files...-in-python
https://www.tutorialspoint.com/sqlite/sqlite_python.htm
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I write a single 8-bit byte to a file? MysticLord 2 298 Sep-03-2020, 12:27 PM
Last Post: MysticLord
  unable to write to log file Mekala 2 321 Aug-12-2020, 11:02 PM
Last Post: Mekala
  List Won't Write in Text File IILawrenceII 4 399 Jul-17-2020, 11:16 PM
Last Post: j.crater
  Importing data from a text file into an SQLite database with Python macieju1974 7 562 Jun-29-2020, 08:51 PM
Last Post: buran
  Process Data from one csv file and write to another CSV file specific column ajin9581 1 371 Jun-17-2020, 06:00 PM
Last Post: buran
  Append JSON's and write to file faqsap 4 562 May-15-2020, 04:20 PM
Last Post: faqsap
  Print/write to file function tpolim008 4 548 Apr-01-2020, 07:59 PM
Last Post: tpolim008
  Write object to file medatib531 7 613 Apr-01-2020, 06:25 PM
Last Post: BrendanD
  iterate through query result bigt 9 674 Mar-26-2020, 04:32 PM
Last Post: bigt
  Replace XML tag and write to the same file krish216 4 617 Mar-26-2020, 07:39 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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