Recent

Author Topic: [REQ] Example Lazarus/SQLite Application  (Read 1971 times)

Picard

  • New Member
  • *
  • Posts: 21
[REQ] Example Lazarus/SQLite Application
« on: June 26, 2019, 03:58:24 pm »
Hopefully someone has a sample like this that does a "TWO WAY LOOKUP".  First of all I'm having trouble connecting a table in an SQLite database that I made to a Pascal application.  I've looked through this forum, YouTube and Google.  I just cannot get them to connect.  Secondly, I need to do a two way lookup just like it's done in this YouTube video, but I need to do it in Pascal.  This example in the Excel video shows what I'm ultimately trying to do with Lazarus and SQLite.  Please help.

Quote
Excel Magic Trick 1480: VLOOKUP & MATCH Two-Way Lookup Quantity & Product to Get Price
https://www.youtube.com/watch?v=GlVzMrGoknA

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7505
Re: [REQ] Example Lazarus/SQLite Application
« Reply #1 on: June 26, 2019, 04:06:06 pm »
I'm sorry, but watching videos in hot weather gives me headaches. How about you just describing what you mean?

Picard

  • New Member
  • *
  • Posts: 21
Re: [REQ] Example Lazarus/SQLite Application
« Reply #2 on: June 26, 2019, 04:15:21 pm »
In my post I describe what I'm trying to do.  I just added a video to help clarify my message. What part of the message in not clear, excluding the video?

MacWomble

  • New Member
  • *
  • Posts: 37
Re: [REQ] Example Lazarus/SQLite Application
« Reply #3 on: June 26, 2019, 04:28:36 pm »
You did not need such a complicated thing like 'Two-Way-Lookup' in Excel.
Just make your SQL-Query to get the right values.

I think you should learn SQL basics first. A simple Query is almost all you need.

'Select product, price from table where qty > 10 and qty < 20'

You have to learn SQL but it's worth it!

what is the problem with your SQLite-connection. You should post the code you have, so that someone could help you.
Mint 18.3 Cinnamon, Codetyphon 6.4 64Bit

Picard

  • New Member
  • *
  • Posts: 21
Re: [REQ] Example Lazarus/SQLite Application
« Reply #4 on: June 26, 2019, 08:47:36 pm »
The first problem is that I've read through this forum, Googled and watched YouTube videos on how to connect a Pascal application to a database and none of the procedures worked in making the connection.  I keep getting errors.  The best way to show you the steps that I took is to make my own video and post a link to it with my explanation of the problem.  I'll have to work on the video and post it when I'm finished.  This will take some time.

With all the discussions of SQLite and Pascal in this forum, I was hoping that someone would already have an example of a portion of their project to share with me.
« Last Edit: June 26, 2019, 08:49:28 pm by Picard »

mangakissa

  • Hero Member
  • *****
  • Posts: 944
Re: [REQ] Example Lazarus/SQLite Application
« Reply #5 on: June 27, 2019, 02:50:29 pm »
take your advantage. Only download sqlite3-64.dll to connect the database on 64 bits otherwise sqlite3.dll
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

Picard

  • New Member
  • *
  • Posts: 21
Re: [REQ] Example Lazarus/SQLite Application
« Reply #6 on: June 28, 2019, 07:54:13 am »
Thanks for your sample project, Mangakissa.  I found sqlite3.dll, but I cannot find sqlite3-64.dll.  Where do I place this library file to compile the project?  I'm on 64 bit Windows 10 and I prefer to use all 64 bit components.  Where do I get sqlite3-64.dll?

Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: [REQ] Example Lazarus/SQLite Application
« Reply #7 on: June 28, 2019, 08:00:31 am »
%WINDIR%\system32
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: [REQ] Example Lazarus/SQLite Application
« Reply #8 on: June 28, 2019, 08:02:56 am »
Download it from here: Precompiled Binaries for Windows
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Picard

  • New Member
  • *
  • Posts: 21
Re: [REQ] Example Lazarus/SQLite Application
« Reply #9 on: June 30, 2019, 03:29:16 am »
Thanks Pascal.  The sqlite3.dll is in the %WINDIR%\system32.  If I'm not mistaken, all the 32 bit libraries are there.  So it seems that there is no sqlite3-64.dll, since the content of the file you advised me to download doesn't call it by that name.  It has the same name as the 32 bit version.

Ok.  Aside from that issue, do I need to place a copy of the dll together with my project folders?

Attached is a screen shot of the tables that I have in my database.  I imported the data from CSV files into SQLite.  Do these tables need to be compiled or is importing the CSV files all that I have to do?
« Last Edit: June 30, 2019, 03:45:36 am by Picard »

bee

  • Sr. Member
  • ****
  • Posts: 360
Re: [REQ] Example Lazarus/SQLite Application
« Reply #10 on: June 30, 2019, 05:16:58 am »
You might want to read this tutorial on how to connect to an sqlite database using sqlDB classes in Free Pascal. It's originally written in Indonesian, but Google Translate could help you read it in any language of your choice.

Example, here's in english. The original text is here.

HTH.
-Bee-

A long time pascal lover.

lucamar

  • Hero Member
  • *****
  • Posts: 2081
Re: [REQ] Example Lazarus/SQLite Application
« Reply #11 on: June 30, 2019, 05:29:43 am »
Thanks Pascal.  The sqlite3.dll is in the %WINDIR%\system32.  If I'm not mistaken, all the 32 bit libraries are there.

I may be wrong but in 64 bit Windows, aren't normal, 64bit libs in system32 and the 32 bit ones in wow64 (or something like that)?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: [REQ] Example Lazarus/SQLite Application
« Reply #12 on: June 30, 2019, 06:51:00 am »
Thanks Pascal.  The sqlite3.dll is in the %WINDIR%\system32.  If I'm not mistaken, all the 32 bit libraries are there.

I may be wrong but in 64 bit Windows, aren't normal, 64bit libs in system32 and the 32 bit ones in wow64 (or something like that)?

Correct!
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

mangakissa

  • Hero Member
  • *****
  • Posts: 944
Re: [REQ] Example Lazarus/SQLite Application
« Reply #13 on: July 01, 2019, 08:32:35 am »
That's why I used TSQLLoadLibrary to find the dll in the place I want ;D
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

Picard

  • New Member
  • *
  • Posts: 21
Re: [REQ] Example Lazarus/SQLite Application
« Reply #14 on: July 01, 2019, 09:21:17 am »
Thanks lucamar.  I remember now that the "wow64" folder is the correct place.  I saw somewhere that the dll also needs to be in one of the project folders.  Is that correct?

I may be wrong but in 64 bit Windows, aren't normal, 64bit libs in system32 and the 32 bit ones in wow64 (or something like that)?