GnuCash c935c2f+
Loading...
Searching...
No Matches
simple_book.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3
6
7import sys
8from gnucash import Session, SessionOpenMode
9
10# We need to tell GnuCash the data format to create the new file as (xml://)
11uri = "xml:///tmp/simple_book.gnucash"
12
13print("uri:", uri)
14with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
15 book = ses.get_book()
16
17 #Call some methods that produce output to show that Book works
18 book.get_root_account().SetDescription("hello, book")
19 print("Book is saved:", not book.session_not_saved())
20
21 #As long as there's no exceptions, book is automatically saved
22 #when session ends.
23 print("saving...")
24
25print("Book is saved:", not book.session_not_saved())