Lazarus Database Overview/es

From Free Pascal wiki
Jump to navigationJump to search

Descripción

Este artículo es una descripción sobre que tipos de bases de datos pueden utilizarse con Lazarus.

Lazarus soporta varios tipos de bases de datos (utilizando e.g. el framework de SQLDB), sin embargo el desarrollador debe instalar los paquetes requeridos (librerías cliente) para cada una.

Se puede acceder a la base de datos por medio de código o ubicando componentes en un formulario. Los componentes data-aware representan campos y se conectan estableciendo la propiedad de fuente de datos (DataSource) de manera que apunte a un TDataSource. El DataSource reoresenta una tabla y se conecta a los componentes de bases de datos (ejemplos: TPSQLDatabase, TSQLiteDataSet) estableciendo la propiedad DataSet. Los componentes data-aware están localizados en la solapa "Data Controls". Los controles DataSource y DataBase están localizados en la solapa "DataAccess".

Lazarus e Interbase / Firebird

  • Por favor ver Firebird en acción para detalles sobre los distintos métodos de acceso, los cuales incluyen:
  1. Soporte incluido internamente de SQLDB.
  2. FBLib.
  3. IBX.
  4. PDO.
  5. Zeos.

Para un tutorial que te guie a través de la manera de crear un GUI (Graphical User Interface) para una base de datos Firebird, ver:

Lazarus y MySQL

  • Por favor echa un vistazo a mysql para más detalles sobre los distintos métodos de acceso, los cuales incluyen:
  1. Soporte Built-in SQLDB.
  2. PDO
  3. Zeos

Lazarus y MSSQL/Sybase

Se puede conectar a un servidor de bases de datos SQL de Microsoft utilizando:

  1. The built-in SQLdb (recientemente con Lazarus/FPC 2.6.1+): TMSSQLConnection (MS SQL) y TSybaseConnection (Sybase ASE)
    1. Para Windows puedes descargar una versión reciente de la librería FreeTDS (disponible en versiones de 32 y 64 bits) dblib.dll desde: | aquí
    1. Not necessary normally: By modifying FPC file dblib.pas SQLDB could use the "native" library ntwdblib.dll instead of the default FreeTDS library dblib.dll (in this case FPC needs to be recompiled).
    1. On Linux by default it uses the FreeTDS library libsybdb.so (for example, in Debian is in package libsybd5).
  1. Zeos component TZConnection (latest CVS, see links to Zeos elsewhere on this page)
    1. On Windows you can choose between native library ntwdblib.dll (protocol mssql) or FreeTDS libraries (protocol FreeTDS_MsSQL-nnnn) where nnnn is one of four variants depending on the server version. For Delphi (not Lazarus) there is also another Zeos protocol ado for MSSQL 2005 or later. Using protocols mssql or ado generates code not platform independient.
    1. On Linux the only way is with FreeTDS protocols and libraries (you should use libsybdb.so).
  1. ODBC (MSSQL and Sybase ASE) with SQLdb TODBCConnection (see also [1])
    1. On Windows it uses native ODBC Microsoft libraries (like sqlsrv32.dll for MSSQL 2000)
    1. On Linux it uses unixODBC + FreeTDS (packages unixodbc or iodbc, and tdsodbc). Since 2012 there is also a Microsoft SQL Server ODBC Driver 1.0 for Linux which is a binary product (no open source) and provides native connectivity, but was released only for 64 bits and only for RedHat.

Please see the FPC and Lazarus help files for details on using SQLDB with Sybase ASE and MSSQL Server.

Light bulb  Nota: In any of the above forms, you can connect using TCP/IP, e.g. on port 1433.

If you use native Microsoft Libraries (over Windows) it could be possible to connect to remote server with Named Pipes. FreeTDS libraries do not support Named Pipes.

Light bulb  Nota: Lazarus 1.0 was released with FPC 2.6.0 and does not include TMSSQLConnection or TSybaseConnection. If you want these, it might be easiest to download a snapshot of the latest Lazarus built with FPC 2.6.1, optinally installing that in a directory different from your Lazarus 1.0 version. You can use --primary-config-path to set up a separate environment for the Lazarus snapshot (see Multiple Lazarus)