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