Delete the Psql database: (in the case of the database Django name:)
Dropdb Django;
Create a new database and belong to Django:
Createdb Django-o Django
When we use the Python manage.py syncdb in Django, we create a new table for the corresponding app in PostgreSQL, but sometimes we find that there are CSRF errors when adding data to the admin management platform. At this point, we will take the following actions:
Python manage.py Sqlsequencereset t1k (Take the t1k application as an example)
It then appears:
BEGIN:
.....
END;
COMMIT;
Copy and enter the above command into the Psql database (Psql Django), paste the command on the command line, and then press the ENTER key. This is done for each application. that resolves the issue.
To transfer data from MySQL to PostgreSQL, you can use the following methods:
First, use the shell to save the contents of the table in the MySQL database as a file:
echo "SELECT * FROM table" | mysql-uroot-p123456 Django >file.txt
At this point, the line break \ r \ n is the reason. Importing the PostgreSQL database directly may cause an error. So:
Sed-i ' s/\r//g ' file.txt
Finally, import the PostgreSQL database: The command is as follows:
Copy "table (name to import)" from '/absolute path/file.txt ';
Complete.
Today I wrote a python program that I want to run on a regular basis.
Therefore, you can do so. Under the Linux system,
Command:
CRONTAB-E open a file.
In this file, enter
*/2 * * * */absolute path/python/absolute path/test.py 1>>log 2>>&1
It means: Run the program every two minutes. Output logs in the log file.
The crontab-l command displays the contents of the file directly.
This article is from the "Blue Fin Dolphin" blog, please be sure to keep this source http://likunheng.blog.51cto.com/9527645/1569911
The things that Django and PostgreSQL databases