Notion API Database Python Implementation
Reason this release was yanked:
Stable version 1.0.0 has been released. Install that version only if migration is not possible.
Project description
Python Notion Database
Notion API Database Python Implementation
created only by database from the official Notion API.
Installing / Getting started
pip install notion-database
import os
import pprint
from notion_database.database import Database
from notion_database.page import Page
from notion_database.properties import Properties, Children
try:
from dotenv import load_dotenv
load_dotenv()
except ModuleNotFoundError:
pass
NOTION_KEY = os.getenv('NOTION_KEY')
PROPERTY = Properties()
PROPERTIES = {
"name": PROPERTY.set_title("title"),
"description": PROPERTY.set_rich_text("description"),
"number": PROPERTY.set_number(1),
"select": PROPERTY.set_select("test1"),
"multi_select": PROPERTY.set_multi_select(["test1", "test2"]),
"checkbox": PROPERTY.set_checkbox(True),
"url": PROPERTY.set_url("www.google.com"),
"email": PROPERTY.set_email("test@test.com"),
"phone": PROPERTY.set_phone_number("010-0000-0000"),
}
# List Database
D = Database(integrations_token=NOTION_KEY)
D.list_databases(page_size=100)
for i in D.result["results"]:
database_id = i["id"]
# Retrieve Database
D = Database(integrations_token=NOTION_KEY)
D.retrieve_database(database_id=database_id)
pprint.pprint(D.result)
# Create Page
P = Page(integrations_token=NOTION_KEY, database_id=database_id)
P.create_page(properties=PROPERTIES, children=[Children().set_body("hello world!")])
# Retrieve Page
page_id = P.result["id"]
P.retrieve_page(page_id=page_id)
pprint.pprint(P.result)
PROPERTIES = {
"name": PROPERTY.set_title("Custom_title"),
"description": PROPERTY.set_rich_text("Custom_description"),
"number": PROPERTY.set_number(2),
}
# Update Page
P.update_page(page_id=page_id, properties=PROPERTIES)
pprint.pprint(P.result)
Building / Developing
python setup.py install
Features
-
list database
-
Retrieve database
-
Create Page object (the database item)
-
update Page object
-
Retrieve Page object
Todo
- query database
Contributing
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
Links
- Notion API : https://developers.notion.com
Licensing
The code in this project is licensed under GPL license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
notion-database-20210513.3.tar.gz
(16.2 kB
view hashes)
Built Distribution
Close
Hashes for notion-database-20210513.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74999705f89bd5a3d6ef91b611cdf7fe28fba0b63af6b4fc37d52767ef24391b |
|
MD5 | 41a5b15e0f3d3837549b7159e2adea7f |
|
BLAKE2b-256 | 00017616949c5f87f6207d0ac6aa1395e30b57a5c5b165ff904558e2877b5328 |
Close
Hashes for notion_database-20210513.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83f30fc1cd398a0b62149d3c736915cbb799a7a37a7bccef84c836bbb1de00c3 |
|
MD5 | ebaf297c16522bb3de4929d63459f14e |
|
BLAKE2b-256 | 06c4ea940ea41d54a2d826689aa9d5b072ea4e26a70cfe047a2b0e76c95895eb |