Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

SimpleConnection

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

SimpleConnection

SimpleConnection is a library responsible for generating database connections and queries in an abstract and simple way.

⚙️ Installation

  • Manual installation: Add the following folders to your project, in Project > Options > Resource Compiler > Directories and Conditionals > Include file search path
pascal
../SimpleConnection/src
  • Installation using the Boss:
pascal
boss install github.com/weslleycapelari/SimpleConnection

🔰 Engines

By default the library uses the most updated component for the delphi version, in this case the most current one is FireDAC, but it is possible to define components through the definition of directives. You can change the engine to make requests. To do this, simply define in: Project > Options > Delphi Compiler > Conditional defines the compiler directive SC_BDE, SC_ADO, SC_DBX or SC_FIREDAC

⚡️ Quickstart

You need to use SimpleConnection

pascal
uses SimpleConnection;
  • Connection
pascal
var
  LConn: IConnection;
begin
  LConn := TConnection.New
    .Silence(True)
    .Engine('Firebird')
    .Hostname('localhost')
    .Port('3050')
    .Database('database.fdb')
    .Username('SYSDBA')
    .Password('masterkey')
    .VendorLib('fbclient.dll')
    .Open;

  if LConn.IsActive then
    ShowMessage('Connected')
  else
    ShowMessage('Not Connected');
end;
  • Query
pascal
var
  LConn : IConnection;
  LQuery: IQuery;
begin
  LConn := TConnection.New
    .Silence(True)
    .Engine('Firebird')
    .Hostname('localhost')
    .Port('3050')
    .Database('database.fdb')
    .Username('SYSDBA')
    .Password('masterkey')
    .VendorLib('fbclient.dll')
    .Open;

  if LConn.IsActive then
  begin
    LQuery := TQuery.New
      .Silence(True)
      .Connection(LConn.Connection)
      .SQL('select * from customer')
      .Open;

    while not LQuery.Eof do
    begin
      ShowMessage(LQuery.FieldAsString('name'));
      LQuery.Next;
    end;
  end;
end;

📝 Samples

A project was developed inside the example folder

💻 Code Contributors

⚠️ License

SimpleConnection is free and open-source software licensed under the Apache-2.0 License.