Difference between revisions of "Zeos tutorial"
m (→Getting Zeos) |
(Cleared out ancient stuff) |
||
Line 5: | Line 5: | ||
This tutorial is about getting, installing and using [http://zeos.firmos.at/portal.php Zeoslib] with [[Glossary#Lazarus|Lazarus]] and [[Glossary#FreePascal|FPC]]. | This tutorial is about getting, installing and using [http://zeos.firmos.at/portal.php Zeoslib] with [[Glossary#Lazarus|Lazarus]] and [[Glossary#FreePascal|FPC]]. | ||
<br> | <br> | ||
− | + | ||
− | |||
== Getting Zeos == | == Getting Zeos == | ||
− | |||
Zeos has recently been ported to [[Glossary#Lazarus|Lazarus]] and there are no releases yet that officially support it but you can easily get it from SVN if you follow these steps: | Zeos has recently been ported to [[Glossary#Lazarus|Lazarus]] and there are no releases yet that officially support it but you can easily get it from SVN if you follow these steps: | ||
=== Windows === | === Windows === | ||
− | |||
* get a SVN client [http://tortoisesvn.tigris.org TortoiseSVN] and install | * get a SVN client [http://tortoisesvn.tigris.org TortoiseSVN] and install | ||
* see [http://tortoisesvn.net/docs/release/TortoiseSVN_en/help-onepage.html#tsvn-dug-general Getting Started with TortoiseSVN] | * see [http://tortoisesvn.net/docs/release/TortoiseSVN_en/help-onepage.html#tsvn-dug-general Getting Started with TortoiseSVN] | ||
Line 19: | Line 16: | ||
=== Linux/BSD === | === Linux/BSD === | ||
− | |||
* get a SVN client (esvn, kdesvn, etc.) | * get a SVN client (esvn, kdesvn, etc.) | ||
* create zeosdbo directory, go in that directory and do | * create zeosdbo directory, go in that directory and do | ||
Line 66: | Line 62: | ||
* Then, in Lazarus, reopen the package (.lpk) and fix the filename cases by clicking on "More..."/"Fix Files Case" | * Then, in Lazarus, reopen the package (.lpk) and fix the filename cases by clicking on "More..."/"Fix Files Case" | ||
* The package should compile now. | * The package should compile now. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Make your first Zeos application == | == Make your first Zeos application == | ||
Line 146: | Line 83: | ||
== More information about working with Zeos == | == More information about working with Zeos == | ||
− | Here you can find some really useful articles explaining Zeos usage and it's internals, some of them | + | Here you can find some really useful articles explaining Zeos usage and it's internals, some of them also talk about Delphi specific stuff but mostly the same techniques can be used in Lazarus too.<br> |
* [http://zeos.firmos.at/kb.php?mode=article&k=6 The ZeosLib DBOs 6.1.5 - With Delphi 7 and Firebird 1.5] | * [http://zeos.firmos.at/kb.php?mode=article&k=6 The ZeosLib DBOs 6.1.5 - With Delphi 7 and Firebird 1.5] | ||
Line 152: | Line 89: | ||
* [http://zeos.firmos.at/kb.php?mode=article&k=5 An Introduction To ZDBC API] | * [http://zeos.firmos.at/kb.php?mode=article&k=5 An Introduction To ZDBC API] | ||
* Also check the [http://zeos.firmos.at/downloads.php Downloads] section for real examples wich can be easily ported to Lazarus. | * Also check the [http://zeos.firmos.at/downloads.php Downloads] section for real examples wich can be easily ported to Lazarus. | ||
− | |||
<br> | <br> | ||
− | |||
== Possible Bugs and Issues == | == Possible Bugs and Issues == | ||
− | + | * I have noticed that sometimes when building Lazarus it cannot find some Zeos files, as a quick workaround try this: | |
− | * I have noticed that | ||
** Use '''Components/Package Graph''' from the main menu. | ** Use '''Components/Package Graph''' from the main menu. | ||
** Open the '''ZComponent''' package. | ** Open the '''ZComponent''' package. | ||
Line 165: | Line 99: | ||
** When asked "Re-Compile this and all required packages?" answer '''[Yes]'''. | ** When asked "Re-Compile this and all required packages?" answer '''[Yes]'''. | ||
** Recompile Lazarus normally (with packages).<br><br> | ** Recompile Lazarus normally (with packages).<br><br> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==See also== | ==See also== | ||
+ | * [http://zeos.firmos.at Forum for ZeosLib] | ||
* [[ZeosDBO]] | * [[ZeosDBO]] | ||
Revision as of 10:06, 16 November 2012
│
Deutsch (de) │
English (en) │
español (es) │
français (fr) │
português (pt) │
русский (ru) │
中文(中国大陆) (zh_CN) │
Overview
This tutorial is about getting, installing and using Zeoslib with Lazarus and FPC.
Getting Zeos
Zeos has recently been ported to Lazarus and there are no releases yet that officially support it but you can easily get it from SVN if you follow these steps:
Windows
- get a SVN client TortoiseSVN and install
- see Getting Started with TortoiseSVN
- do Checkout from Windows Explorer: http://svn.code.sf.net/p/zeoslib/code-0/trunk
Linux/BSD
- get a SVN client (esvn, kdesvn, etc.)
- create zeosdbo directory, go in that directory and do
- svn checkout http://svn.code.sf.net/p/zeoslib/code-0/trunk
Installing the components
This is a tricky part so you should have a little patience and read this part carefully.
- Make sure you have the latest Lazarus snapshot and the at least FPC 2.0.3 not older than 6th March 2006.
- Start one instance of Lazarus.
- Use Components/Open Package File(.lpk) from the main menu.
- Go to zeosdbo_rework\packages\lazarus\ and open zcomponent.lpk
- Press [Compile] only if you don't want to install the components into the IDE
- Press [Install]
- You are asked if you want to recompile Lazarus.
- Answer [Yes] this time.
- Wait until compilation ends, Lazarus should restart itself after that.
- If all is ok you should now be able to see the [Zeos Access] tab in the Component Palette.
If you receive the error "Cannot find unit ZClasses" or something similar, then you need to carefully check the case of the filenames in your Zeos source distribution.
- Even if the cases match exactly, the autogenerated package source file can generate the wrong case name in the uses clause (Lazarus 0.9.18), i.e.:
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit Zcore;
interface
uses
Zclasses, Zcollections, Zcompatibility, Zexprparser, Zexprtoken, Zexpression,
Zfunctions, Zmatchpattern, Zmessages, Zsysutils, Ztokenizer, Zvariables,
Zvariant;
implementation
end.
- Notice that Lazarus has named the unit ZClasses Zclasses, resulting in a naming conflict. Presumably this is a bug in Lazarus, not the Zeos packages. One way around this is to rename all the zeos source files to lowercase. Trawl through each subdirectory under src/ and execute this command in a bash window:
rename -v 'y/A-Z/a-z/' *
- Then, in Lazarus, reopen the package (.lpk) and fix the filename cases by clicking on "More..."/"Fix Files Case"
- The package should compile now.
Make your first Zeos application
- Drop a ZConnection.
- Set your User, Password, Host, Port and Protocol (and any other params if needed).
- Set Connected to True.
- Drop a ZQuery (do not mistake with ZReadOnlyQuery).
- Set the Connection to your active ZConnection.
- Set the Sql property to something like SELECT * FROM MyTable
- Set Active to True.
- Drop a DataSource from the [Data Access] tab.
- Set the DataSet to your active ZQuery.
- Drop a DBGrid from the [Data Controls] tab.
- Set the Datasource to your DataSource.
- If all is ok you should now be able to see the records from your table.
More information about working with Zeos
Here you can find some really useful articles explaining Zeos usage and it's internals, some of them also talk about Delphi specific stuff but mostly the same techniques can be used in Lazarus too.
- The ZeosLib DBOs 6.1.5 - With Delphi 7 and Firebird 1.5
- Overview of the Zeos Database Objects Architecture
- An Introduction To ZDBC API
- Also check the Downloads section for real examples wich can be easily ported to Lazarus.
Possible Bugs and Issues
- I have noticed that sometimes when building Lazarus it cannot find some Zeos files, as a quick workaround try this:
- Use Components/Package Graph from the main menu.
- Open the ZComponent package.
- Right Click on the Files item in the list.
- Choose [Recompile all required].
- When asked "Re-Compile this and all required packages?" answer [Yes].
- Recompile Lazarus normally (with packages).