Creating new customer with Python bindings and SQL backend
Jonas Lippuner
jonas at lippuner.ca
Fri Jun 7 04:20:30 EDT 2013
-----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-----
More information about the gnucash-devel
mailing list