GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
simple_sqlite_create.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 ## @file
3 # @brief Example Script simple sqlite create
4 # @ingroup python_bindings_examples
5 
6 from gnucash import Session, Account
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'), is_new=True)
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()