Is there a mechanism for converting a database created with  sqlite to 
postgres backend? The built in tryton client backup/restore doesn't work, 
it appears to back up using the databases internal mechanism. I have been 
using this 
http://hg.tryton.org/tryton-tools/file/tip/sqlite2pg.py
But there are a number of columns coming from the sqllite database that are 
coming across as the wrong type. ie Ints for bool and strings for floats so 
far the changes look like the following, but perhaps a better approach 
would be is to look at the target tables column types to do the 
conversions..


        for row in sqlite_cursor:
values = "";
crow = []
for index, x in enumerate(columns):
crow.append(row[index])
if row[index] is not None and \
   (row[index]==1 or row[index]==0) and \
(x == "active" or \
x=="fuzzy" or \
x=="translatable" or \
x=="direct_print" or \
x=="window_name" or \
x=="window" or \
x=="perm_read" or \
x=="perm_create" or \
x=="perm_write" or \
x=="perm_delete" or \
x=="noupdate" or \
x=="repeat_missed" or \
x=="global_p" or \
(x=="rounding" and table!="currency_currency") or \
x=="n_cs_precedes" or \
x=="p_sep_by_space" or \
x=="p_cs_precedes" or \
x=="taxes_parent" or \
x=="n_sep_space" or \
x=="consumable" or \
x=="purchasable" or \
x=="salable" or \
x=="delivery" or \
x=="update_posted" or \
x=="deferral" or \
x=="reconcile" or \
x=="balance_sheet" or \
x=="income_statement" or \
x=="invoice" or \
x=="manual" or \
x=="taxes_category" or \
x=="account_parent" or \
x=="account_category" or \
x=="n_sep_by_space" or \
x=="default_p" ):
values += ",'%s'"
else:
if index>0:
values +=","
if crow[index] is not None:
if x=="rounding" and table=="currency_currency":
crow[index] =float(crow[index] )
if x=="rate" and table=="currency_currency_rate":
crow[index] =float(crow[index] )
if x=="cost_price" and table=="stock_move":
crow[index] =float(crow[index] )
if x=="unit_price" and table=="stock_move":
crow[index] =float(crow[index] )
if x=="balance_sheet" and table=="account_account_type_template":
crow[index] =float(crow[index] )
if x=="invoice_tax_sign" and table=="account_tax":
crow[index] =float(crow[index] )
if x=="rate" and table=="account_tax":
crow[index] =float(crow[index] )
if x=="credit_note_base_sign" and table=="account_tax":
crow[index] =float(crow[index] )
if x=="credit_note_tax_sign" and table=="account_tax":
crow[index] =float(crow[index] )
if x=="invoice_base_sign" and table=="account_tax":
crow[index] =float(crow[index] )
if x=="divisor" and table=="account_invoice_payment_term_line":
crow[index] =float(crow[index] )
if x=="amount" and table=="account_invoice_payment_term_line":
crow[index] =float(crow[index] )
if x=="percentage" and table=="account_invoice_payment_term_line":
crow[index] =float(crow[index] )
if x=="unit_price" and table=="account_invoice_payment_line":
crow[index] =float(crow[index] )
if x=="unit_price" and table=="account_invoice_line":
crow[index] =float(crow[index] )
if x=="base_sign" and table=="account_invoice_tax":
crow[index] =float(crow[index] )
if x=="tax_sign" and table=="account_invoice_tax":
crow[index] =float(crow[index] )
if x=="base" and table=="account_invoice_tax":
crow[index] =float(crow[index] )
if x=="amount" and table=="account_invoice_tax":
crow[index] =float(crow[index] )
if x=="total_amount_cache" and table=="sale_sale":
crow[index] =float(crow[index] )
if x=="untaxed_amount_cache" and table=="sale_sale":
crow[index] =float(crow[index] )
values += "%s"
print (query % values)
pg_cursor.execute((query % values),crow)

Reply via email to