- Timestamp:
- Feb 16, 2015, 11:37:47 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 31 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineMySQL.pas
r7 r12 6 6 7 7 uses 8 Classes, SysUtils, UDatabase ;8 Classes, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary; 9 9 10 10 type 11 12 { TDatabaseMySQL } 13 11 14 TDatabaseMySQL = class(TDatabaseClient) 12 15 private 16 procedure LoadTables; 17 public 18 SqlDatabase: TSqlDatabase; 19 constructor Create; override; 20 destructor Destroy; override; 21 procedure Load; override; 22 procedure Save; override; 13 23 end; 14 24 15 25 implementation 16 26 27 { TDatabaseMySQL } 28 29 procedure TDatabaseMySQL.LoadTables; 30 var 31 DbRows: TDbRows; 32 NewTable: TTable; 33 I: Integer; 34 begin 35 DbRows := TDbRows.Create; 36 try 37 SqlDatabase.Query(DbRows, 'SELECT `TABLE_NAME` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = "' + SqlDatabase.Database + '"'); 38 for I := 0 to DbRows.Count - 1 do begin 39 NewTable := TTable.Create; 40 NewTable.Database := Database; 41 NewTable.Name := (TDictionaryStringString(DbRows[I])[0]).Value; 42 NewTable.Caption := NewTable.Name; 43 Database.Tables.Add(NewTable); 44 end; 45 finally 46 DbRows.Free; 47 end; 48 end; 49 50 constructor TDatabaseMySQL.Create; 51 begin 52 inherited Create; 53 SqlDatabase := TSqlDatabase.Create(nil); 54 end; 55 56 destructor TDatabaseMySQL.Destroy; 57 begin 58 SqlDatabase.Free; 59 inherited Destroy; 60 end; 61 62 procedure TDatabaseMySQL.Load; 63 var 64 URL: TURL; 65 begin 66 URL := TURL.Create; 67 try 68 URL.AsString := Database.ConnectionString; 69 if URL.Scheme <> 'mysql' then 70 raise Exception.Create('Wrong connection string. Required mysql protocol.'); 71 72 SqlDatabase.HostName := URL.Host.AsString; 73 if URL.Port <> 0 then 74 SqlDatabase.Port := URL.Port; 75 SqlDatabase.UserName := URL.UserName; 76 SqlDatabase.Password := URL.Password; 77 if Copy(URL.Path, 1, 1) = '/' then 78 SqlDatabase.Database := Copy(URL.Path, 2, High(Integer)); 79 SqlDatabase.Connect; 80 LoadTables; 81 finally 82 URL.Free; 83 end; 84 inherited Load; 85 end; 86 87 procedure TDatabaseMySQL.Save; 88 begin 89 SqlDatabase.Disconnect; 90 inherited Save; 91 end; 92 17 93 end. 18 94 -
trunk/DbEngines/UEngineXML.pas
r8 r12 6 6 7 7 uses 8 Classes, SysUtils, DOM, XMLRead, XMLWrite, UDatabase, UXMLUtils, FileUtil; 8 Classes, SysUtils, DOM, XMLRead, XMLWrite, UDatabase, UXMLUtils, FileUtil, 9 UHtmlClasses; 9 10 10 11 type … … 46 47 47 48 function TDatabaseXML.GetFileName: string; 48 begin 49 if Copy(Database.ConnectionString, 1, 8) = 'file:///' then 50 Result := Copy(Database.ConnectionString, 8, High(Integer)) 51 else Result := ''; 49 var 50 URL: TURL; 51 begin 52 URL := TURL.Create; 53 try 54 URL.AsString := Database.ConnectionString; 55 if URL.Scheme <> 'file' then 56 raise Exception.Create('Wrong connection string. Required file scheme.'); 57 58 Result := URL.Path 59 finally 60 URL.Free; 61 end; 52 62 end; 53 63 -
trunk/Languages/MyData.cs.po
r11 r12 400 400 msgid "Do you want to really remove table '%s' ?" 401 401 msgstr "Opravdu chcete odstranit tabulku '%s'?" 402 403 #: usqldatabase.sdatabasequeryerror 404 msgid "Database query error: \"%s\"" 405 msgstr "" 406 -
trunk/Languages/MyData.po
r11 r12 392 392 msgstr "" 393 393 394 #: usqldatabase.sdatabasequeryerror 395 msgid "Database query error: \"%s\"" 396 msgstr "" 397 -
trunk/MyData.lpi
r10 r12 68 68 </local> 69 69 </RunParams> 70 <RequiredPackages Count=" 5">70 <RequiredPackages Count="6"> 71 71 <Item1> 72 <PackageName Value="CoolWeb"/> 73 <DefaultFilename Value="Packages/CoolWeb/CoolWeb.lpk" Prefer="True"/> 74 </Item1> 75 <Item2> 72 76 <PackageName Value="TemplateGenerics"/> 73 77 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 74 </Item 1>75 <Item 2>78 </Item2> 79 <Item3> 76 80 <PackageName Value="CoolTranslator"/> 77 81 <DefaultFilename Value="Packages/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 78 </Item2>79 <Item3>80 <PackageName Value="FCL"/>81 82 </Item3> 82 83 <Item4> 84 <PackageName Value="FCL"/> 85 </Item4> 86 <Item5> 83 87 <PackageName Value="Common"/> 84 88 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 85 </Item 4>86 <Item 5>89 </Item5> 90 <Item6> 87 91 <PackageName Value="LCL"/> 88 </Item 5>92 </Item6> 89 93 </RequiredPackages> 90 94 <Units Count="17"> … … 215 219 <SearchPaths> 216 220 <IncludeFiles Value="$(ProjOutDir)"/> 217 <OtherUnitFiles Value="Forms;DbEngines "/>221 <OtherUnitFiles Value="Forms;DbEngines;/usr/lib/mysql/;/usr/lib64/mysql/"/> 218 222 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 219 223 </SearchPaths> -
trunk/MyData.lpr
r10 r12 10 10 Forms, UFormTables, UDatabase, UCore, Common, CoolTranslator, UEngineXML, 11 11 UFormTable, UFormRecords, UFormRecord, UFormFields, UFormField, UDataTypes, 12 TemplateGenerics, UEngineMySQL, UEngineSQLite, UFormMain, UFormConnect,13 UForm Databases, UFormPreferences;12 TemplateGenerics, CoolWeb, UEngineMySQL, UEngineSQLite, UFormMain, 13 UFormConnect, UFormDatabases, UFormPreferences; 14 14 15 15 {$R *.res} -
trunk/UDatabase.pas
r9 r12 156 156 TDatabaseClient = class 157 157 Database: TDatabase; 158 constructor Create; virtual; 158 159 procedure Load; virtual; 159 160 procedure Save; virtual; … … 206 207 207 208 { TDatabaseClient } 209 210 constructor TDatabaseClient.Create; 211 begin 212 end; 208 213 209 214 procedure TDatabaseClient.Load;
Note:
See TracChangeset
for help on using the changeset viewer.