The things that Django and PostgreSQL databases

Source: Internet
Author: User
Tags postgresql psql

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.