"Column 'tx_guid' cannot be null"

26 views
Skip to first unread message

Jeffrey Honig

unread,
Dec 19, 2017, 12:59:24 AM12/19/17
to piecash
I'm attempting to get piecash to record transactions to my mysql backed GnuCash book and am running into this error:

sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (_mysql_exceptions.OperationalError) (1048, "Column 'tx_guid' cannot be null") [SQL: u'INSERT INTO splits (guid, tx_guid, account_guid, memo, action, reconcile_state, reconcile_date, value_num, value_denom, quantity_num, quantity_denom, lot_guid) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: ('5d580b426f9142f4ac63183410f1bbd9', None, '01fcbb6b2aece5c7ba17d737a9fa5f02', '', '', 'n', None, -58600, 100, -58600, 100, None)]

My code that creates a transaction looks like this:

splits = []
splits.append(piecash.Split(account=providerp,
value=-trans.total))
if ucr:
splits.append(piecash.Split(account=providerp,
memo="UCR",
value=ucr))
splits.append(piecash.Split(account=providerp,
memo=trans.insurer.name + " Paid",
value=trans.paid))
splits.append(piecash.Split(account=insurerp,
value=trans.paid))

gtrans = piecash.Transaction(currency=book.default_currency,
post_date=trans.service_date,
enter_date=datetime.datetime.now(),
num=trans.number,
description=trans.description,
splits=splits)

As far as I can see I am following the examples in the docs.

I'm using GnuCash 2.6.17.

Any help would be appreciated.

Thanks.

Jeff

Sébastien de Menten

unread,
Dec 19, 2017, 1:04:45 AM12/19/17
to Jeffrey Honig, piecash
Tx Jeffrey for this bug report/question.
It may be better if you post this issue as a GitHub issue on https://github.com/sdementen/piecash/issues as it will be easier to track.
And I'll have a look at it ...
Have you tried the same script on the book saved as a SQLite file ? Just to check if it is a MySQL specific issue

--
You received this message because you are subscribed to the Google Groups "piecash" group.
To unsubscribe from this group and stop receiving emails from it, send an email to piecash+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/piecash/dcaf3219-c2d4-4bfe-95dc-c1f70555beb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeffrey Honig

unread,
Dec 19, 2017, 9:18:39 AM12/19/17
to piecash
I filed this as #48.  I'll try exporting to SQLite and follow up there.
To unsubscribe from this group and stop receiving emails from it, send an email to piecash+u...@googlegroups.com.

Jeffrey Honig

unread,
Dec 19, 2017, 6:59:48 PM12/19/17
to piecash
The issue was passing currency directly as book.default_currency:

  gtrans = piecash.Transaction(currency=book.default_currency,
                                         post_date=trans.service_date,
                                         enter_date=datetime.datetime.now(),
                                         num=trans.number,
                                         description=trans.description,
                                         splits=splits)


As sdementen pointed out, the right way to do this is:

  curr = book.default_currency
  gtrans = piecash.Transaction(currency=curr,

                                         post_date=trans.service_date,
                                         enter_date=datetime.datetime.now(),
                                         num=trans.number,
                                         description=trans.description,
                                         splits=splits)  


Reply all
Reply to author
Forward
0 new messages