Add migration script
This commit is contained in:
parent
b070cb067e
commit
40cc410369
2 changed files with 32 additions and 0 deletions
|
@ -6,3 +6,4 @@ Simple blog management system.
|
|||
2. Add pagination links
|
||||
4. Find a nice way to display metadata (author, dates, etc)
|
||||
5. Allow adding pages (pinned articles ?)
|
||||
6. Add syntax coloration to code blocks
|
||||
|
|
31
migration.py
Normal file
31
migration.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import sqlite3
|
||||
|
||||
|
||||
def main():
|
||||
writefreely = sqlite3.connect("writefreely.db")
|
||||
db = sqlite3.connect("db.sqlite3")
|
||||
writefreely_c = writefreely.cursor()
|
||||
db_c = db.cursor()
|
||||
writefreely_c.execute(
|
||||
"SELECT slug, created, updated, view_count, title, content FROM posts;"
|
||||
)
|
||||
for line in writefreely_c.fetchall():
|
||||
db_c.execute(
|
||||
"INSERT INTO articles_article(title, content, status, published_at, created_at, updated_at, author_id, views_count, slug) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||
(
|
||||
line[4],
|
||||
line[5],
|
||||
"published",
|
||||
line[1],
|
||||
line[1],
|
||||
line[2],
|
||||
1,
|
||||
line[3],
|
||||
line[0],
|
||||
),
|
||||
)
|
||||
db.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in a new issue