lazdbexport: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | **lazdbexport** is a package that supplies components to facilitate database export. It is delivered with lazarus and may be installed by using \[Package\|Install/Uninstall packages\]. After install the components are accessible via the Data Export tab. It provides a template class for descendants that can provide export of datasets. Also included are various ready-made descendants for: | |
| 2 | 2 | ||
| 3 | 3 | | icon | Component | Description | | |
| 4 | 4 | |----|----|----| | |
| 5 | 5 | |  | [[TCSVExporter]] | CSV | | |
| 6 | 6 | |  | [[TFixedlengthExporter]] | Fixed length | | |
| 7 | 7 | |  | [[TSQLExporter]] | SQL | | |
| 8 | 8 | |  | [[fpXMLXSDExport|TXMLXSDExporter]] | XML/XSD | | |
| 9 | 9 | |  | [[TSimpleXMLExporter]] | XML | | |
| 10 | 10 | |  | [[TSimpleJSONExporter]] | json | | |
| 11 | 11 | |  | [[fpdbfexport|TFPDbfExport]] | dbf | | |
| 12 | 12 | |  | [[TTeXExporter]] | TeX | | |
| 13 | 13 | |  | [[TRTFExporter]] | RTF | | |
| 14 | 14 | |  | [[TStandardExportFormats]] | | | |
| 15 | 15 | |  | [[TFPDataExporter]] | | | |
| 16 | 16 | ||
| 17 | 17 | As indicated, developers can write their own export classes using the export framework. An example of this is the Excel/spreadsheet format exporter in [[FPSpreadsheet]] | |
| 18 | 18 | ||
| 19 | 19 | ## Import | |
| 20 | 20 | ||
| 21 | 21 | There is no corresponding import to dataset code in FPC/Lazarus, but there is third party code like dbimport (https://bitbucket.org/reiniero/smalltools/src, directory dbimport). | |
| 22 | 22 | ||
| 23 | 23 | DbImport is used in the [LazSQLX](http://lazsqlx.wordpress.com/) and [TurboBird](http://code.sd/products/turbobird/) database management tools for importing CSV (like) data into datasets. | |
| 24 | 24 | ||
| 25 | 25 | Another form of import is the use of [[TSQLScript]]; an exported database with [[TSQLExporter]] can be imported with the use of [[TSQLScript]]. | |
| 26 | 26 | ||
| 27 | 27 | ## Example | |
| 28 | 28 | ||
| 29 | 29 | See the examples in your FPC source directory \$(fpcdir)\source\packages\fcl-db\tests (see [[Databases|Running FPC database tests]]), specifically testdbexport.pas. | |
| 30 | 30 | ||
| 31 | 31 | Following is a simplest form of using TCSVExporter. **fpcsvexport** must be included in uses clause. | |
| 32 | 32 | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 33 | + | ``` pascal | |
| 34 | + | if SaveDialog1.Execute then | |
| 35 | + | with TCSVExporter.Create(nil) do begin | |
| 36 | + | Dataset:= BufDataSet1; | |
| 37 | + | FileName:= SaveDialog1.FileName; | |
| 38 | + | Execute; | |
| 39 | + | Free; | |
| 40 | + | end; | |
| 41 | + | ``` | |
| 40 | 42 | ||
| 41 | 43 | --- | |
| 42 | 44 | *From the Free Pascal wiki, page "lazdbexport", as it stood on 2021-08-16 after a change by Egsuh, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
