Aug-26-2019, 10:30 PM
the paragraph to import information data from a database cursor to the prettytable,there is the command :
mytable = from_cursor(cursor)
does not work and creates an error.
at one video in youtube I remark that I must write it like that : mytable = from_db_cursor(cursor)
my final works now correctely
after installing prettytable by : pip install PTable
and :
thanks for the link of the prettytable
mytable = from_cursor(cursor)
does not work and creates an error.
at one video in youtube I remark that I must write it like that : mytable = from_db_cursor(cursor)
my final works now correctely
after installing prettytable by : pip install PTable
and :
from prettytable import from_db_cursor
#Fonction pour creer un fichier texte et sauvegarder dedans le contenu de la bdd : def create_file_from_loc35R(self): script_path_ils35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant new_path_ils35R=script_path_ils35R + '\\data_base' #concaténer au path ci-dessus le path du dossier data_base os.makedirs(new_path_ils35R, exist_ok=True) #creer le dossier data_base au nouveau path script_path_filesave_loc35R = os.path.dirname(os.path.realpath(__file__))#récupérer le répertoire courant new_path_filesave_loc35R=script_path_filesave_loc35R + '\\filesave' #concaténer au path ci-dessus le path du dossier data_base os.makedirs(new_path_filesave_loc35R, exist_ok=True) #creer le dossier data_base au nouveau path try: conn = sqlite3.connect (new_path_ils35R+'\\ils35R.db') curseur=conn.cursor() c=curseur.execute("SELECT * FROM loc35R") mytable = from_db_cursor(c) table_txt = mytable.get_string() local_dir = os.path.dirname(__file__) with open(os.path.join(local_dir, "filesave/loc35R.txt"), "w",encoding="utf-8") as file_loc35R: file_loc35R.write(table_txt) except : self.messageInfo_filesave()there is the output text file :
thanks for the link of the prettytable