Creating new customer with Python bindings and SQL backend

Tom Lofts dev at loftx.co.uk
Fri Jun 7 04:33:08 EDT 2013


Hi Jonas,

I believe this issue relates to a bug in the Python bindings discussed here: https://bugzilla.gnome.org/show_bug.cgi?id=700197 and resolved Guncash 2.5.2

As the bug relates to one of the Python files you should be able to resolve it by patching the relevent file in your 2.4 installation rather than upgrading.

If you need any more information on this please let me know.

Kind regards,

Tom

-----Original Message-----
From: gnucash-devel-bounces+dev=loftx.co.uk at gnucash.org [mailto:gnucash-devel-bounces+dev=loftx.co.uk at gnucash.org] On Behalf Of Jonas Lippuner
Sent: 07 June 2013 09:21
To: gnucash-devel at gnucash.org
Subject: Creating new customer with Python bindings and SQL backend

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello guys,

I am trying to create a new customer using the Python bindings. I am using an SQL backend (PostgreSQL).

I follow the examples and do

new_customer = Customer(book, '0', USD, 'foo bar')

Of course, the currency USD is correctly defined. This gives my the following SQL errors

* 00:57:26  CRIT <gnc.backend.dbi> [pgsql_error_fn()] DBI error:
ERROR:  null value in column "currency" violates not-null constraint

* 00:57:26  CRIT <gnc.backend.dbi>
[conn_execute_nonselect_statement()] Error executing SQL INSERT INTO
customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable)
VALUES('daf13116dcc180990154e1652c3cab09','','10','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL)
* 00:57:26  CRIT <gnc.backend.sql> [gnc_sql_do_db_operation()] SQL
error: INSERT INTO
customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable)
VALUES('daf13116dcc180990154e1652c3cab09','','10','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL)
* 00:57:26  CRIT <gnc.business> [gncCustomerOnError()] Customer QofBackend Failure: 12
* 00:57:26  CRIT <gnc.backend.dbi> [pgsql_error_fn()] DBI error:
ERROR:  null value in column "currency" violates not-null constraint

* 00:57:26  CRIT <gnc.backend.dbi>
[conn_execute_nonselect_statement()] Error executing SQL INSERT INTO
customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable)
VALUES('daf13116dcc180990154e1652c3cab09','foo
bar','10','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL)
* 00:57:26  CRIT <gnc.backend.sql> [gnc_sql_do_db_operation()] SQL
error: INSERT INTO
customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable)
VALUES('daf13116dcc180990154e1652c3cab09','foo
bar','10','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL)
* 00:57:26  CRIT <gnc.business> [gncCustomerOnError()] Customer QofBackend Failure: 12


Looking at the Python code, it seems that the Customer object is first created without passing the value of its ID, currency or name. Thus the SQL error is legitimate.

When I execute the exact same code on an XML backend, it works as expected.


So now my question is, how do I create a new customer on an SQL backend?


Thanks for the help,
Jonas


- --
My email is signed and I encrypt email on request.
To verify my signature or send me encrypted email, get my public key: http://lippuner.ca/key -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRsZfLAAoJELH92qHy0gntDvMQANXpnVv8QSJU8YdEOxqlT4mA
lkSCvw19F8QXsYIArQ1TR7UTDa1Rwtr0RPzuaqY+wXFLTCv7GnToJzT1f88T36OX
1si6BCQZALGwYh1gvraLMD0Y8JjMW8sQySFjDRO5FpBKLzZ0X4GZq64H/nZvt3dl
TsRYZmsQ61rjg87+HUT1XH6ROsIvyso0lw9fQ1Ju6PxUuk7e2ybheaZjzvEDmgJu
4zZkVB53+QR7sZacE74S2I09ffoMLQ8Xd8+EEIkZsdNiGFQtlVZpQlXqQH1w9PE4
pTuyY1l0vTmNZQkxyzo51VBO98KH+l13uomnhAPY5e/64SUBJKV578NM9qqFR+2E
YgRlrBMJz/jvk88TfT5eGPsCaqmq20Ka5s2Ozqsz7RCA4W6beBYU7vq3BN030GVt
Q49galjp8CsX9z5RkNc61g2Uq2yVp9bSn3CFnjSYO5LWDdmdj2UCiy7CIu6+b77V
Ldy/qX1LIgl3kQX+bv5uJ70nRrBcC4D2IzPIkXOeG7poqZ587zSsYyq9p2OZCqHE
uhzT+jgN+pqJbZvo3sZBEZvTuIk1h2ID12ev3HWKqslh2zwOWUG154BH5lEKEJ/Y
QOL0Hlzsj5AdBAayevS8IqahQRuAOjzeJBqU9xQdt+DBMG9Q4cPTsNys0p7XR4Lf
Egs4tloSIgdaREkKoetO
=J+xU
-----END PGP SIGNATURE-----
_______________________________________________
gnucash-devel mailing list
gnucash-devel at gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel




More information about the gnucash-devel mailing list