Thank you Clemens. I'm using Python2. I was thinking about moving from PosgreSQL to MariaDB becuse the 'import_from_csv_file' don't works. I was thinking that is was a Psycog2 library problem, but it's the same with mariaDB.
Now I have a MariaDB DB, and for achieving your suggestions I must use import_from_csv_file. And it don't works, there's not any error. [user@server web2py7]$ source env/bin/activate (env) [user@server web2py7]$ cd web2py (env) [user@server web2py]$ python web2py.py -S myapp -M -P web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2020 Version 2.20.4-stable+timestamp.2020.05.03.05.18.50 Database drivers available: sqlite3, psycopg2, pyodbc, pymysql, imaplib Python 2.7.16 (default, Nov 1 2020, 19:29:00) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> filename = 'myfile.csv' >>> db.import_from_csv_file(open(filename, 'rb')); db.commit() After that there's no feedback and the DB still empty. What could affect like that the import_from_csv_file function? Il giorno mercoledì 25 novembre 2020 alle 20:29:00 UTC+1 Clemens ha scritto: > I'm using the csv export in a simple controller, thus the user (admin) can > have a db backup on one click: > (the path and filename in my app is dynamic and not fixed as follows, > simplified for better understanding) > if sys.version_info[0] == 2: > db.export_to_csv_file(open('<path_to_your_backup>/<filename>.csv', > 'wb')) > else: > db.export_to_csv_file(open('<path_to_your_backup>/<filename>.csv', > 'w', encoding='utf-8', newline='')) > > To recover a database I'm using the console as follows: > python <your_path_to_web2py>/web2py/web2py.py -S > <your_application_by_name> -M -P > >>> filename = '<path_to_your_backup>/<filename>.csv' > >>> db.import_from_csv_file(open(str(filename), 'r', encoding='utf-8')); > db.commit() > or for python2 > >>> db.import_from_csv_file(open(filename, 'rb')); db.commit() > > Regards > Clemens > > > > > On Wednesday, November 25, 2020 at 6:53:45 PM UTC+1 gaelpri...@gmail.com > wrote: > >> Hello. >> >> After the migration from Webfaction to Opalstack I'm still having some >> troubles with PostgreSQL. >> In a first time I was unable to run he scheduler workers, but now >> installing the Psycog2 library like that this problem is resolved. >> pip2 install uwsgi psycopg2-binary http://effbot.org/downloads/ >> Imaging-1.1.7.tar.gz >> >> My scheduler tasks import in tables some csv files. >> Depending of the functions I have: >> No errors, but the tables still empty. >> This ticket: <class '_csv.Error'> line contains NULL byte >> >> That's quite difficult to understand where's the problem. >> >> I was thinking to clone the PostgreSQL db to a MariaDB one. >> >> How can I do that? >> >> Thanks. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/ac9e7dde-e8d8-402a-b397-c6f514b0c067n%40googlegroups.com.