In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Django data how to migrate data from sqlite to MySQL, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
I quickly built my own knowledge base yesterday. I feel like I have a lot of things to do all of a sudden, at least make myself comfortable.
Unexpectedly, with this gadget, I found that I had a real slash-and-burn information collection. Why do you say that, because we read a lot of articles every day, if you decide to collect it, just silently click "collect" in Wechat, and then unwittingly, you have collected hundreds or thousands of articles. The disadvantage of Wechat's collection of articles is that it is very difficult for us to manage them on the mobile phone, which can be searched by keywords or other tags, but only about 3-4 messages can be displayed on the screen. If things like sorting by time are basically impossible, I've always wondered if I don't see a powerful tool to manage favorites.
This is only the mobile end, if it is the computer side, then more, our browser has favorites, but does not have its own sorting function, if you want to do more screening, basically depends on the eye.
And what is more complicated is that sometimes when all the articles are turned over at once, it will make people a little dizzy, and as a bookmark, there is no sense of hierarchy.
Even if you do a detailed classification, but a directory will inevitably generate a large number of links, completely unable to sort.
So I chose to write some links in my daily work records, but this is obviously even worse, because I can't find the information at all. So it's sad to think about how much important information I've lost.
Then I made up my mind to improve my life first, such as the following url management style, where I can specify the rules for sorting. Split multiple categories, and more importantly, based on web, if you use Django's admin template, you don't have to write front-end pages at all.
So I used the configuration in windows. In order to simplify, I used sqlite to store data and quickly configured more than 30 pieces of url information.
The big categories are divided into these, so you can see that what I want to do is not a simple url collection, but to make it more interesting. It is not limited to the technical direction.
Having said so, we immediately encounter a potential problem. The database is sqlite, but we must actually use MySQL. In terms of use and data security, we prefer to use MySQL, but sqlite and MySQL themselves are not completely compatible, how to synchronize the data.
Managing sqlite is simple. The data is stored in a file that looks ordinary. We only need to parse this one file. It is more suitable for embedded and does not support transactions.
How to synchronize sqlite data to MySQL is a problem in front of me.
I made a quick attempt, using the following way, for reference only.
Copy the data file of sqlite to linux, because all my official services are under linux, and I use MySQL for the same application. The advantage of this data file is that it can be copied from windows to linux and can be parsed normally. Log in and use the command sqlite3.
Look at the database of sqlite as follows, with slightly different syntax and commands.
Sqlite > .resume
Seq name file
0 main / root/test/db.sqlite3
The tables that currently exist are these.
Sqlite > .tables
Auth_group django_content_type
Auth_group_permissions django_migrations
Auth_permission django_session
Auth_user km_child_category
Auth_user_groups km_parent_category
Auth_user_user_permissions km_url_info
Django_admin_log
How to synchronize so many tables is actually a choice. The information in the models.py we built is needed, which means that we only need to synchronize three of the tables.
We can easily export data using the .dump option.
Sqlite3 db.sqlite3 .dump
The resulting SQL is similar to the following form, and most of the syntax is compatible.
CREATE TABLE "km_parent_category" ("category_pid" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "category_name" varchar NOT NULL, "category_memo" varchar (200) NOT NULL)
INSERT INTO "km_parent_category" VALUES (1 test1')
INSERT INTO "km_parent_category" VALUES (2) MySQL (2)
INSERT INTO "km_parent_category" VALUES (3Jing 'personal account article', 'jianrong-notes')
INSERT INTO "km_parent_category" VALUES (4 'Humanities and History',')
If you want to export csv, add the-csv option, or generate a .sql file directly.
If it is a sql file, you need to remove the "" from the script, or the parsing will make an error.
When we deploy SQL to MySQL, we have a closed loop, and we can supplement and improve it according to our own ideas.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.