Xׯd0 ddlZddlZddlmZddlmZddlmZddl m Z ddl Z eddd Z Gd d eZ e e jjd Ze e je jfd Ze e je jdZe e je jjdZe e je jje jdZe e je jjdZe e je jjdZe e jdZe e jdZe e jje jjdZ e e je jjdZ!e e je jje jdZ"e e je jje je jdZ#e e je jje je jdZ$e e je jje je jdZ%e e je jje je jdZ&e e je jje je jdZ'e e jj(e jje je je jfe j)dZ*e e je jje jj(dZ+e e jj(e jje jdZ,e e je jje jj-d Z.e e je jje jj-d!Z/e e je jje jj-d"Z0e e je jje jj-d#Z1e e je jje jj-d$Z2dS)%N)GenericReverseEngineering) DefineModule)server_version_str2tuple)NotConnectedError DbSQLiteREz Oracle Corp.z1.0)nameauthorversionceZdZedZedZedZedZedZedZ edZ edZ ed Z ed Z ed Zed Zd S)SQLiteReverseEngineeringcdS)NSQLite)clss ..\modules\db_sqlite_re_grt.pygetTargetDBMSNamez*SQLiteReverseEngineering.getTargetDBMSName$sxc2|j|jdS)Nr ) _connections__id__r connections r serverVersionz&SQLiteReverseEngineering.serverVersion(s 129==rcd} ||} |dstdn=#t$r0}t jd|jztdd}~wwxYwn#t$r}t jd|jztj |j d}|s#t j dt|d |j dzd z|j d <t jd d |i|j |j<Yd}~nd}~wwxYw|r||d d}t jdd|jd|t'|dz}tj}|dd\|_|_|_|_||j |jd<dS)aEstablishes a connection to the server and stores the connection object in the connections pool. It first looks for a connection with the given connection parameters in the connections pool to reuse existent connections. If such connection is found it queries the server to ensure that the connection is alive and reestablishes it if is dead. If no suitable connection is found in the connections pool, a new one is created and stored in the pool. Parameters: =========== connection: an object of the class db_mgmt_Connection storing the parameters for the connection. password: a string with the password to use for the connection (ignored for SQLite). NzSELECT 1zconnection errorz1Connection to %s apparently lost, reconnecting...zConnection errorzConnecting to %s...dbfilezConnection failed'wbcopytables_connection_string ConnectedrzSELECT sqlite_version()rz SQLite REz Connected to z, )rrrrr )get_connectioncursorexecute Exceptiongrt send_infohostIdentifierrsqlite3connectparameterValues send_errorstrrr execute_queryfetchonelog_inforrclasses GrtVersion majorNumber minorNumber releaseNumber buildNumber)rrpasswordconexcver ver_partsr s rr)z SQLiteReverseEngineering.connect-s1 F$$Z00C <zz||++J778#$67778 < < < QT^Tmmnnn'(:;;; <8 ! F F F M/*2KK L L L/*">EcdgS)z2Returns a list of the available catalogs. defrrs rgetCatalogNamesz(SQLiteReverseEngineering.getCatalogNamesXs wrctjtj|jddgS)z;Returns a list of schemata for the given connection object.rr)ospathsplitextbasenamer*)rr catalog_names rgetSchemaNamesz'SQLiteReverseEngineering.getSchemaNames^s;  !1!1*2LX2V!W!WXXYZ[\\rcFd}d|||DS)NzNSELECT name FROM sqlite_master WHERE type='table' AND NOT name LIKE 'sqlite_%'cg|] }|d S)rr).0rows r z:SQLiteReverseEngineering.getTableNames..isGGG3AGGGr)r-)rrrC schema_namequerys r getTableNamesz&SQLiteReverseEngineering.getTableNamesds03HG#"3"3J"F"FGGGGrcgSNrrrrCrJs r getViewNamesz%SQLiteReverseEngineering.getViewNamesk rcgSrNrrOs rgetProcedureNamesz*SQLiteReverseEngineering.getProcedureNamesorQrcLtjdd||||}tjdd|dd}d}||r$t |||dndz }tjdd |rd}||d D]\} } } } } td vs| r| d r)| d d dd} tj dd| ztj j || |tjd||z zd| z|dz }tjdd|S)Nrz'Reverse engineering catalog informationg?z Preparing...reverseEngineerTablesTg|=zGathered statszSELECT * FROM sqlite_master)viewtriggersqlite_[]r zProcessing this sql: %s;zObject %s reverse engineered!r g?zReverse engineering completed!)r% send_progresscheck_interruptionreverseEngineerCataloggetlenrLr-type startswithreplace log_debugmodulesMysqlSqlFacadeparseSqlScriptString)rrrC schemata_listcontextcatalog get_tablestotalidx object_typertbl_name_sqls rreverseEngineerz(SQLiteReverseEngineering.reverseEngineerws !FGGG    ,,ZFF #~...[[!8$??  ZS&&z<DDEEEYZZ #/000  C7:7H7HUr7s7s  3 T8Q...c.X=P=PQZ=[=[.kk#r**223;; 8:UX[:[\\\ *??MMM&&(((!#e "35TW[5[\\\q #?@@@rctj}||_|j|jj|||pdg}|j |D]n}tj }||_||_ t|dr| |||j|o|S)NrVreverseEngineerSequences)r%r0db_mysql_CatalogrsimpleDatatypesextend_rdbmsrDschemata remove_alldb_mysql_Schemaownerhasattrrtappend)rrrCrjschemata_namesrJschemas rr^z/SQLiteReverseEngineering.reverseEngineerCatalogs+..00# &&sz'ABBB++J EEM"##%%%) , ,K[0022F%FK"FLs677 A,,Z@@@   # #F + + + +rcdSrNr)rrtables rgetCommentForTablez+SQLiteReverseEngineering.getCommentForTable rcdSrNr)rrrjs rreverseEngineerUserDatatypesz5SQLiteReverseEngineering.reverseEngineerUserDatatypesrrN)__name__ __module__ __qualname__ classmethodrrr)r=rDrLrPrSrrr^rrrrrr r #s^[>>[>''['T[ ]][] HH[H [[""["J[$  [   [   rr c6tdS)Nzsqlite_rdbms_info.xml)r initializeDBMSInforrrrrs # 6 67N O OOrc4tSrN)r getDataSourceNamesrrrrrs # 6 6 8 88rc6t|SrN)r quoteIdentifier)rs rrrs # 3 3D 9 99rc6t|SrN)r fullyQualifiedObjectName)objs rrrs # < rso,777777444444222222 \ ne T T T U U U U U 8U U U v 3;,--PP.-P CHcj)**99+*9 3:sz**::+*: 3:s{9::BB;:B 37CK:CJGGBBHGB 37CK:;;;;<;; 37CK:;;<<<;< 3:888 38>>> 3;)3;+IJJAAKJA 38S[;<<@@=<@ 38S[;SZHHMMIHM 38S[;SZTTYYUTY 38S[;SZTTXXUTX 38S[;SZTT[[UT[ 38S[;SZTT]]UT] 38S[;SZTT\\UT\ 3;)3;+I3:X[X`beblWmorowxxffyxf 37CK:CK