python - Importing a large SQL file into a local Firebird database -


i'm trying import large sql file (15k+ statements) new local firebird database python, through fdb module.

import fdb  db = fdb.create_database("create database 'test.fdb'") sql_str = open('test.sql').read() in_trans = false  stmt in sql_str.split(';'):     if stmt.startswith('insert') , not in_trans:         in_trans = true         db.begin()     else:         in_trans = false         db.commit()      db.execute_immediate(stmt) 

i haven't found better way this... (like using sort of executescript() in sqlite3 module executes multiple statements per call).

it worked first few statements, stopped , raised exception:

fdb.fbcore.databaseerror: ('error while executing sql statement:\n- sqlcode: -104\n- dynamic sql error\n- sql error code = -104\n- client sql dialect 0 not support reference bigint datatype', -104, 335544569) 

from read in firebird documentation, i've use sql dialect 3 able use bigint datatype in table schemas. i'm correctly setting database sql dialect 3 fdb.create_database() default arguments, i'm still need set client sql dialect , i've no idea , how that. i'm using firebird 2.5.2 , python 2.7.2 on os x.

as far know, fdb should default dialect 3, can specify explicitly using connection property dialect=3, see example 2 in connecting database. weird thing though there no such thing dialect 0 in firebird.

if solve problem, i'd suggest file bug in issue tracker driver should default dialect 3: http://tracker.firebirdsql.org/browse/pyfb


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -