Files
gnucash/bindings/python/example_scripts/simple_sqlite_create.py
c-holtermann b06801185c shebang should be specific to python version (PEP394)
preferred form is #!/usr/bin/env python3 as gnucash now only works with
python3
2019-04-04 17:48:42 +02:00

26 lines
603 B
Python

#!/usr/bin/env python3
## @file
# @brief Example Script simple sqlite create
# @ingroup python_bindings_examples
from gnucash import Session, Account
from os.path import abspath
from gnucash.gnucash_core_c import ACCT_TYPE_ASSET
s = Session('sqlite3://%s' % abspath('test.blob'), is_new=True)
# this seems to make a difference in more complex cases
s.save()
book = s.book
root = book.get_root_account()
a = Account(book)
root.append_child(a)
a.SetName('wow')
a.SetType(ACCT_TYPE_ASSET)
commod_table = book.get_table()
a.SetCommodity( commod_table.lookup('CURRENCY', 'CAD') )
s.save()
s.end()