Connect with Postgresql

Asked

Viewed 467 times

3

I have a file *.ini which connects to my Firebird database, but now I need this file configured to connect to Postgresql

[IBConnection]
DriverName=Interbase          
Database=192.168.1.30:C:\testes\impressoes.fdb         
RoleName=RoleName         
User_Name=sysdba         
Password=masterkey        
ServerCharSet=             
SQLDialect=3               
ErrorResourceFile=        
LocaleCode=0000         
BlobSize=-1        
CommitRetain=False           
WaitOnLocks=True                     
Interbase TransIsolation=ReadCommited         
Trim Char=False     

What I need is to find out what needs to be changed to connect with Postgresql instead of Firebird.

Inside the code is so the connection:

inserir a descrição da imagem aqui

Connection with Devart:

inserir a descrição da imagem aqui

But whenever I try to access some table to check if the connection is OK, comes the following error message:

inserir a descrição da imagem aqui

I believe that he found my database, but I have no idea why he says that such a table does not exist

The error that he was showing was occurring due to the table being with the name all in uppercase letter, when putting in lowercase letter the error did not occur again but when I try to access some information of the bank it is accusing another error now:

inserir a descrição da imagem aqui

However this Fmtbcdfield is not available as variable format, which I believe is since the error compares with the Integer format of the variable.

  • 1

    In some specific language?

  • @rray Actually, nowadays there is already an application that uses Firebird as a database, I did not touch the application but if I am not mistaken the language that was used was Delph, I will edit the question and put everything that is in the file . ini for you to have a better idea

  • I think the change is that the server’s database and ip are in different fields. Still it’s hard to understand the question

  • @rray I recreated all the tables that existed inside this file impressoes.fdb in Postgresql, but I don’t know how to change the connection so that instead of continuing to save the information inside the Firebird database it will be saved in postgresql

  • 1

    What you want is for your system to stop connecting to Firebird and connect to Postgresql ? If so, it may be that your application does not work since it uses a component to access a Firebird database and not Postgresql.

  • I believe that creating a new section ([PGConnection]) with the fields, Drivername, User_name, Password, Database (base name only) and Host (server ip) is sufficient but remember that the application should read this new pattern.

  • 1

    It makes sense @Jcsaint probably within the application she is making the changes in the database. I will need to look at the application first. Thanks for the help

  • I will try to make these changes @rray if it works put here.

  • @rray there in Database you just said the name of the base, what would that be?

  • That’s right, when looking at the application edit the question in more detail :)

  • @rray I was able to access the source code and changed the question to show where the connection is (I’m not sure if it is right there that the connection is determined) but from that image you would have some idea of what it would take to connect to Postgresql instead of to Firebird?

  • I can’t say, I would try to look for something like 'postgres connection via dbexpress'.

Show 7 more comments

1 answer

2


Friend by the image you posted your application was created using Delphi 7 and it did not natively support Postgresql connection, however there are dbexpress drivers that add support to Postgresql connection.

The Devart has drive for dbexpress, you can check here https://www.devart.com/dbx/postgresql/

Find the Delphi 7-specific version, download, then close the Delphi IDE and install the drive, then open it again and edit the connection settings by selecting the new option that appears in the Connection Name that will probably be as Pgsqlconnection, then change the parameters to the specific ones of your Postgresql server.

  • I edited the question to show how was the dbExpress configuration window with Devart, that’s what you were trying to say?

  • There is some reason why the information is incomplete, and others it is bringing up (Memo) instead of the data

  • R.Santos what is happening is that the data types mapped by the postgresql drive are different from those mapped in the datasets by the Firebird drive. In this last error message he is saying exactly that he was expecting the field code in the dataset to be of the Fmtbcdfield type but this mapped in the dataset as integer.

  • In the newer versions of the Devart drive there are type mapping settings and you can set for example a numeric field of your database ex. Numeric(15,0) be mapped to integer instead of float which is the pattern he is mapping. Take a look at this link from Devart http://blog.devart.com/data-type-mapping-in-delphi-data-components.html

  • 1

    Thanks for all the help @Diego Garcia, you can tell if it is only paid the?

  • R. Santos as far as I know is paid only yes. But I do not think it is so expensive so it is proposed outside that the performance of their drives are much superior to the native versions of Delphi in the old versions before firedac.

  • It is also worth remembering that to solve this problem that you had of the types in a slightly more laborious way and without the mapping is possible also you just have to find the dataset that gave problem (clientdataset, query, sqldataset), right click on it, select the Fielddefs option, remove the problematic field and add again by right-clicking and selecting the add Fields option. With this the field will be recreated but with the new format.

  • I know it doesn’t have to do with the topic, but can you tell me if it’s possible and how do you add a connection to postgresql via ODBC in Delphi 7? It’s just that it’s kind of expensive for Devart to acquire, and via ODBC would also solve my problem

  • Where you say in solving my problem with the type, you are referring to the format of the fields in the bank?

  • R. Santos was actually talking about solving the second problem that you had after you put the Devart drive, so you didn’t have to set up the mapping.

  • To use ODBC you need to use Adoconnection and not dbexpress, so just set up the Connection string and use, but I think you’ll get more work this way.

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.