WordPress-style content management with block-based pages, stored as JSON files on disk instead of MySQL.

0 downloads

dbbasic-content/examples/wordpress_migration.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-content.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-content.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-content.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Release v0.2.0 - Pages support 25b7e5e 1 year, 1 month ago History
wordpress_migration.py · 1.2 KB · 44 lines
1"""
2WordPress migration example.
3
4Shows how to import content from WordPress database.
5"""
6
7from dbbasic_content import WordPressImporter, ContentDB
8
9# Import from WordPress database
10with WordPressImporter(
11 host='localhost',
12 database='wordpress',
13 user='root',
14 password='secret'
15) as importer:
16 # Import all content
17 stats = importer.import_to('/var/app/content')
18
19 print("Import complete!")
20 print(f" Posts: {stats['posts']}")
21 print(f" Pages: {stats['pages']}")
22 print(f" Drafts: {stats['drafts']}")
23 print(f" Total: {sum(stats.values())}")
24
25# Verify imported content
26content = ContentDB('/var/app/content')
27posts = content.get_posts()
28
29print(f"\nVerification: Found {len(posts)} posts in content directory")
30
31# Show sample post
32if posts:
33 sample = posts[0]
34 print(f"\nSample post:")
35 print(f" Slug: {sample['slug']}")
36 print(f" Title: {sample['title']}")
37 print(f" Blocks: {len(sample['blocks'])}")
38
39# Show categories and tags
40categories = content.get_categories()
41tags = content.get_tags()
42
43print(f"\nCategories: {', '.join(categories)}")
44print(f"Tags: {', '.join(tags[:10])}..." if len(tags) > 10 else f"Tags: {', '.join(tags)}")