mirror of https://github.com/Gnucash/gnucash
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
642 B
26 lines
642 B
#!/usr/bin/env python3
|
|
## @file
|
|
# @brief Example Script simple sqlite create
|
|
# @ingroup python_bindings_examples
|
|
|
|
from gnucash import Session, Account, SessionOpenMode
|
|
from os.path import abspath
|
|
from gnucash.gnucash_core_c import ACCT_TYPE_ASSET
|
|
|
|
s = Session('sqlite3://%s' % abspath('test.blob'), SessionOpenMode.SESSION_NEW_STORE)
|
|
# 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()
|