Python Forum
[PyQt] saving text file by FileDialog option
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] saving text file by FileDialog option
#5
but with prettytable librairy I save the text file with correct positioning of the columns
with this code :

from prettytable import from_db_cursor

def create_file_from_database(self):
  
    conn = sqlite3.connect ('database.db')
    curseur=conn.cursor()           
    c=curseur.execute("SELECT * FROM table")

    mytable = from_db_cursor(c)
    table_txt = mytable.get_string()

    with open("textFile.txt", "w",encoding="utf-8") as file_loc35R:
        file_loc35R.write(table_txt)

    conn.commit()
    curseur.close()
    conn.close()  
ther is the picture of text file with nice display

[Image: tykx.jpg]
Reply


Messages In This Thread
RE: saving text file by FileDialog option - by atlass218 - Feb-08-2020, 08:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Saving file to html or pdf stopped working in PyQt6 ejKDE 4 953 Mar-12-2024, 07:45 PM
Last Post: ejKDE
  [Tkinter] filedialog, open a file error liketocode 4 3,684 Dec-07-2022, 10:51 PM
Last Post: liketocode
  [Tkinter] logical error - saving file rwahdan 4 2,331 Jul-01-2021, 12:59 PM
Last Post: rwahdan
  [Tkinter] Exclude hidden file, filedialog.askopenfile red380sl 1 3,263 Dec-01-2020, 07:04 PM
Last Post: DT2000
  [Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename JackMack118 10 5,206 Dec-29-2019, 08:12 PM
Last Post: JackMack118
  Part of code is adding extra new line when saving to text file. lovepeace 9 5,328 Aug-24-2019, 12:52 PM
Last Post: lovepeace
  Update value selected in option menu when select an item from text box klllmmm 2 5,141 Jun-06-2019, 04:51 AM
Last Post: klllmmm
  tkinter filedialog and pickle - custom icon question. kim07133 0 2,831 Jan-08-2018, 12:10 PM
Last Post: kim07133
  [Tkinter] filedialog. FULL SCREEN issac_n 0 3,223 Dec-05-2017, 07:33 AM
Last Post: issac_n

Forum Jump:

User Panel Messages

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