notion2pg-bulk 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ """
2
+ Notion Workspace to PostgreSQL Migration Tool
3
+ """
4
+ from .migrator import NotionMigrator
5
+
6
+ __all__ = ["NotionMigrator"]
notion2pg_bulk/cli.py ADDED
@@ -0,0 +1,69 @@
1
+ """
2
+ Command line interface for the Notion to PostgreSQL migration tool.
3
+ """
4
+
5
+ import argparse
6
+ import os
7
+ import sys
8
+ import sqlalchemy as sa
9
+ from .migrator import NotionMigrator
10
+
11
+
12
+ def main():
13
+ """Main CLI entry point."""
14
+ parser = argparse.ArgumentParser(
15
+ description="Migrate Notion workspace to PostgreSQL database"
16
+ )
17
+
18
+ parser.add_argument(
19
+ "--notion-token",
20
+ help="Notion integration token (or set NOTION_TOKEN env var)"
21
+ )
22
+
23
+ parser.add_argument(
24
+ "--database-url",
25
+ help="PostgreSQL connection string (or set DATABASE_URL env var)"
26
+ )
27
+
28
+ parser.add_argument(
29
+ "--extract-page-content",
30
+ action="store_true",
31
+ help="Extract free-form content from page bodies (slower migration)"
32
+ )
33
+
34
+ parser.add_argument(
35
+ "--quiet",
36
+ action="store_true",
37
+ help="Run in non-interactive mode (skip validation steps and progress bars)"
38
+ )
39
+
40
+ args = parser.parse_args()
41
+
42
+ # Get credentials
43
+ notion_token = args.notion_token or os.getenv("NOTION_TOKEN")
44
+ if not notion_token:
45
+ print("❌ Error: Notion token required. Set --notion-token or NOTION_TOKEN env var")
46
+ return 1
47
+
48
+ database_url = args.database_url or os.getenv("DATABASE_URL")
49
+ if not database_url:
50
+ print("❌ Error: Database URL required. Set --database-url or DATABASE_URL env var")
51
+ return 1
52
+
53
+ # Create database connection
54
+ engine = sa.create_engine(database_url)
55
+
56
+ # Initialize and run migrator
57
+ migrator = NotionMigrator(
58
+ notion_token=notion_token,
59
+ db_connection=engine,
60
+ interactive_mode=not args.quiet,
61
+ extract_page_content=args.extract_page_content
62
+ )
63
+
64
+ migrator.run()
65
+ return 0
66
+
67
+
68
+ if __name__ == "__main__":
69
+ sys.exit(main())