GnuCash  5.6-150-g038405b370+
simple_sqlite_create.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
5 
6 from gnucash import Session, Account, SessionOpenMode
7 from os.path import abspath
8 from gnucash.gnucash_core_c import ACCT_TYPE_ASSET
9 
10 s = Session('sqlite3://%s' % abspath('test.blob'), SessionOpenMode.SESSION_NEW_STORE)
11 # this seems to make a difference in more complex cases
12 s.save()
13 
14 book = s.book
15 root = book.get_root_account()
16 a = Account(book)
17 root.append_child(a)
18 a.SetName('wow')
19 a.SetType(ACCT_TYPE_ASSET)
20 
21 commod_table = book.get_table()
22 a.SetCommodity( commod_table.lookup('CURRENCY', 'CAD') )
23 s.save()
24 
25 s.end()
STRUCTS.