Lazarus

Programming => Databases => Topic started by: majid.ebru on May 13, 2017, 10:42:18 am

Title: [SOLVED][SQLite] : i can't see table
Post by: majid.ebru on May 13, 2017, 10:42:18 am
Hi
i make a project and i want to see my table but i can't see.
i see my table in sqlite IDE.
help me please
 :'( :'(
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 13, 2017, 11:04:28 am
Hello majid.ebro.

I tested your code but I can't make it work. Where can I find zcomponent?
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 13, 2017, 11:10:47 am
Zeos sh*t maybe?

Anyway it works with:
Code: Pascal  [Select][+][-]
  1.     ZConnection1: TSqlite3Connection;
  2.     ZQuery1: TSqlQuery;
  3.  

@Handoko: you can install zeos with the online package manager. (And, like me, uninstall it again later ;) )

You will also see that the query doesn't have the datasource connected, duh!
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 13, 2017, 11:16:15 am
sorry :-[

you can download zeos from here (https://sourceforge.net/projects/zeoslib/)
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 13, 2017, 11:31:29 am
Connect the query to the datasource otherwise you won't see much  :P
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 13, 2017, 12:23:23 pm
sorry
i don't understand what you say?!??! %) %) %)
.
can you more explain,please
and
how can i solve i?
.

this sample works corectly?!?!
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 13, 2017, 01:00:32 pm
Hooray, it works!  :)

I haven't tested "base", but your first one "TestShow" works. It works almost effortlessly on my test, I just need to configure the path and some settings. I use Linux.

Thanks Thaddy for recommending Online Package Manager. I heard it a lot but this is my first time using that tool. Nice, I will keep using it.
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 13, 2017, 01:22:07 pm
Also works (the same) on WIN64
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 13, 2017, 04:33:04 pm
Hooray, it works!  :)

I haven't tested "base", but your first one "TestShow" works. It works almost effortlessly on my test, I just need to configure the path and some settings. I use Linux.

Thanks Thaddy for recommending Online Package Manager. I heard it a lot but this is my first time using that tool. Nice, I will keep using it.

Wooooooooooooo
 :o :o :o :o :o :o
.
.
oh my god
.
that is true
.
what is my wrong?
what is my problme?
.
help please!!
Title: Re: [SQLite] : i can't see table
Post by: valdir.marcos on May 13, 2017, 05:12:25 pm
what is my wrong?
what is my problme?

Please, study bellow information and try SQLDB components instead of ZEOS components:
http://wiki.freepascal.org/Working_With_TSQLQuery
http://wiki.freepascal.org/SqlDBHowto
http://wiki.freepascal.org/SQLite

If your have any other doubt, please come back here.
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 13, 2017, 06:19:26 pm
The problem is that he forgot to set the datasource property. (That's for sure) He did not say if that fixed it yet.
The only other issue I can think of is a wrong version of sqlite installed. Unlikely, but possible.
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 13, 2017, 06:55:17 pm
no
the "base.rar" works corectlly.
.
i just see  this clip (https://www.youtube.com/watch?v=2_aM-CR0c8M) and then build the "Base.rar"
.
then i want to change program but i don't know what i changed?
.
ok
.
thank you very much for answer
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 13, 2017, 07:18:21 pm
but i don't know what i changed?

Write a log of "recent changes" and/or use version control software. If don't want to use version control software, keep several backups of the working code and use Meld => http://meldmerge.org/

Forget what have changed that damaged the code?  >:D
That's often happens (on beginners only). So don't repeat same mistakes. Learning programming is one thing, learning how to write code better is a different thing.
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 13, 2017, 10:59:38 pm
@majid.ebru,

FieldName not assigned.

( ZQuery1.ExecSQL; // not needed)

Michal
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 13, 2017, 11:04:43 pm
@Thaddy,

Zeos sh*t maybe?
Can you justify it?

Michal
Title: Re: [SQLite] : i can't see table
Post by: valdir.marcos on May 14, 2017, 03:13:29 am
Write a log of "recent changes" and/or use version control software. If don't want to use version control software, keep several backups of the working code and use Meld => http://meldmerge.org/

I have just tested Lazarus 1.6.4\Tools\Compare File to Notepad++ 7.3.3 Plugin Compare 2.0.0 and I realized why you suggest Meld, which I didn't know yet.

I thought that Lazarus Compare Tool would be visually similar to Microsoft Visual Studio Diff Windows:
https://www.visualstudio.com/en-us/docs/tfvc/compare-files

When needed I was using TortoiseSVN, TortoiseGIT, Notepadd++ Compare Plugin or WinMerge.
http://winmerge.org/

Is there another compare plugin that I could use inside Lazarus IDE?
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 14, 2017, 07:28:50 am
@Thaddy,
Can you justify it?
Michal

The code is a mess. There are many (100'ths) of places where during compilation there are unsolved warnings, some of which are very, very nasty to solve afterwards by third party developers that just work with the PPU's. That goes from range checks to string conversions with data loss. If these were just in the visual components as side effect I maybe could live with that but at least the engine and middleware non-visual parts should be completely free of warnings that could be errors. That's because it is database software and I don't want corruption. To summarize: the sourcecode is not very re-assuring to say the least.

Also, the error handling is crude or even missing in places where it matters most: the checks and versioning of some of the third party engines lacks, so everything has the possibility to grind to a halt from which it can not recover. (The above code is a good example if the sqlite dll is wrong 32/64 or 2 vs 3) Causes a permanent hang, even crashed Lazarus during debugging.

Since there is a lot of potential, every now and then I still try it out, but nothing seems to change in the code quality. The authors should start with solving all warnings. Then solve the problems when the third party shared libraries/dll's are not what is expected and make it possible to recover gracefully on the low level side, not my exception handling way up my high-level code.

There's *a lot* more, but these are the most demonstrable and both the main issues have to do with lazy and sloppy coding.
Summary: code quality is bad, exception handling is bad. Ideas are good, execution is sloppy.

And this easy to verify:
By just recompiling the zeos packages. Count the warnings. Count the warnings you don't want to see in database software...
Try to load  a wrong dll in the above code by OP and compile ... (save everything first, it can crash Lazarus as well as the exe)

[edit]
Note those range checks should really be solved and are easy to solve:
Most of them are either a variable of the wrong type, but with the same width: *must* be solved because of the sign bit. Either adapt the variable type, use an intermediate assignment or typecast.
The string types must be examined and when proven harmless also solved with an explicit typecast or the string type should be changed. Or better: the string types should be explicit. Not "string".
All of this won't affect Delphi compatibility.
The exception handling and subsequent recovery probably requires a re-design.

And please do not use unit wide {$rangechecks off} or {$R-}. I'd like to do that myself, thank you, on a program wide basis.
Although I would allow
Code: Pascal  [Select][+][-]
  1. {$ifdef fpc}{$push}{$R-}<the code><{$pop}{$endif}
in some rare but not all cases.

As it stands it is feature rich but poorly written software. I like the features. I don't like the code.
It is poorly written because the programmers most certainly are very good.
They just fall into the "I am a programming God, so I know better than the compiler" trap.
Warnings should be solved. If only to make sure the developer has taken a look at what the compiler thinks could potentially be wrong.
And in this particular case the compiler is right most of the time.

[edit2]
Read my later posting on the component editors...
http://forum.lazarus.freepascal.org/index.php/topic,36869.msg246159.html#msg246159
That's a pretty serious deployment issue!.
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 14, 2017, 12:01:05 pm
Hi
i don't know waht is happen??but i compile it in my laptop with lazarus 1.6.2 and it works corectly.
thanks a lot
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 14, 2017, 12:21:09 pm
Hi
i don't know waht is happen??but i compile it in my laptop with lazarus 1.6.2 and it works corectly.
thanks a lot
Your problem has also to do with the above critical write-up on Zeos, btw.
You have a problem with hard coded paths or library versions.
One could say that is also the fault of Zeos's component editors.
They cause you to enter a hard-coded full path.

Experienced programmers can work around that. Less experienced programmers like you need help to solve that.

Zeos developers take note! Offer option to use system default path for libraries (32 AND 64 bit). Offer option to make path relative.

Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 14, 2017, 12:52:22 pm
i don't know waht is happen??but i compile it in my laptop with lazarus 1.6.2 and it works corectly.

If you just stop here then you learn nothing from this 'auto-solved by itself' issue. I recommend you to inspect the code carefully, check the differences between your recent compilation and the previous compilation. Is it the hardware, software, library, code or configuration problem?!!! This is a good example for you to learn how to debug. Novice programmers are too eager to learn coding but forget debugging is a very important thing in software development.

Seriously, when something not working previously becomes working and you don't know what you have done or what has happened. This is very dangerous, the code may contain a hidden bug that may cause cataclysm in the future.  :'( :'( :'( :'( :'( :'( :'(

Anyway, your project is not commercial program so no serious harm may happen.  :D
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 14, 2017, 12:59:55 pm
@Handoko
In his favor is that he is lead to believe - by his components - to produce working code.
Properly written software (in this case even for software development) would have prevented him from making that assumption.
Yes, majid.ebru made not a mistake perse, but made an assumption that can be easily made.

Zeos is highly recommended by some. Even I see its promise. But their code needs cleaning up. Big time.
In my past and current experience it is simply highly unstable. Which is unforgivable for software development libraries.
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 14, 2017, 01:14:03 pm
Zeos is highly recommended by some. Even I see its promise. But their code needs cleaning up.

I agree. It was my first time trying Zeos and maybe the last. It seems easy to use and very feature-rich, but 154 hints and all are z related.  :o
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 14, 2017, 01:42:27 pm
@Handoko,

Download the current(development) version:
https://sourceforge.net/p/zeoslib/code-0/HEAD/tree/branches/testing-7.2/ (https://sourceforge.net/p/zeoslib/code-0/HEAD/tree/branches/testing-7.2/)
http://zeoslib.sourceforge.net/viewtopic.php?f=3&t=40782 (http://zeoslib.sourceforge.net/viewtopic.php?f=3&t=40782)

Michal
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 14, 2017, 02:38:05 pm
Does that attend the very basic issues I explained?
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 14, 2017, 02:39:06 pm
Done as what miab3 said.

The development version doesn't seem good. Also, I'm not familiar with Delphi - I may be wrong, but maintaining multiple version packages for Delphi - I don't think it is a good idea.
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 14, 2017, 03:09:52 pm
@Handoko,

This is an idea commonly used in Delphi.

Michal
Title: Re: [SQLite] : i can't see table
Post by: Thaddy on May 14, 2017, 03:19:35 pm
@Handoko & Michal
That's also necessary for Lazarus and FPC if you want to maintain older versions of the compiler and the LCL.
It's less of an issue for FPC and Lazarus because users can be pointed to a new and updated FREE compiler and IDE.
This is fine, multiple packages for multiple versions. That's even how it should be.

My critique is more fundamental.
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 14, 2017, 07:26:02 pm
Thanks a lot
.
this is first my program about DataBase.
.
i just see a clip then i create a program.
.
i am beginner about Database and i try to learn more about it.
.
i don't know that the ZEOS is good or not.
.
.
tell(and guide) me ,please,Which component should I use ؟
or
Which component is better?(less bug aand....)
.
Quote

version control software
.
.
 Meld => http://meldmerge.org/


in future i will use Meld .
please Introduction about "version control software"
.
thank you veeeeeeeery much
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 14, 2017, 07:32:48 pm
valdir.marcos has given you the suggestion, check the previous post.

I do not use version control software, so I let other to answer.
Title: Re: [SQLite] : i can't see table
Post by: valdir.marcos on May 15, 2017, 04:35:21 am
tell(and guide) me ,please,Which component should I use ؟

what is my wrong?
what is my problme?

Please, study bellow information and try SQLDB components instead of ZEOS components:
http://wiki.freepascal.org/Working_With_TSQLQuery
http://wiki.freepascal.org/SqlDBHowto
http://wiki.freepascal.org/SQLite


Quote
in future i will use Meld .
please Introduction about "version control software"

When needed I was using TortoiseSVN, TortoiseGIT, Notepadd++ Compare Plugin or WinMerge.
http://winmerge.org/

About version control software, take a look on these links:
https://en.wikipedia.org/wiki/Version_control
https://www.atlassian.com/git/tutorials/what-is-version-control
Git Basics - Training:
https://www.youtube.com/playlist?list=PLg7s6cbtAD165JTRsXh8ofwRw0PqUnkVH
https://www.youtube.com/user/GitHubGuides/playlists
https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
https://www.getfilecloud.com/blog/2015/02/top-5-open-source-version-control-tools-for-system-admins/#.WRkMtWc2yUk
https://tortoisegit.org/

https://www.slideshare.net/Ocramius/svn-basic-tutorial
http://www.tutorialspoint.com/svn/
Subversion Basics with TortoiseSVN Tutorial, AssemblaVideo:
https://www.youtube.com/watch?v=fPUdXvjY_G4
https://tortoisesvn.net/
Title: Re: [SQLite] : i can't see table
Post by: mangakissa on May 15, 2017, 08:55:01 am
My opinion.

If you come from delphi and always use ZEOS, please do also (even the multiple warnings from the compiler are forgiven).

If you are new to database programming (even with pascal) use the installed basic components.
SQLdb is very powerfull for a lot of databases.
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 15, 2017, 11:15:47 am
Hi
i understand what is my wrong ?!?!? %) %)

stages of Project :

1-i create application project
2 - i put a Zconnection1 and a ZQuery1 and a Datasource1 and a DBGrid1 in form
3 - Zconnection1 :
         3 - 1 : DataBase address : ...
         3 - 2 : LibraryLocation address : ....
         3 - 3 : Protocol : sqlite-3
         3 - 4 : Connection : True
4 - ZQuery1 :
         4 - 1 : connection := Zconnection1
         4 - 2 : SQL : SELECT * FROM "Person"
         4 - 3 : double click on ZQuery and add Fildes of Table
5 - Datasource1
         5 - 1 : Dataset : ZQuery1
6 - DBGrid
         6 - 1 : DataSource : DataSource1
         6 - 2 : double click on DBGrid and add some Fildes(Titles) :o :o :o

i just don't do stage 6-2 and project work correctly and evry thing are OK.
.
Thank you from all.
 :) ;) :D ;D :) ;) :D ;D
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 15, 2017, 11:25:42 am
So, everything is working correctly, right?

When something doesn't work as what we want, we should review what we have or have not done. I'm glad to see you wrote your step-by-step and made a review about it.
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 15, 2017, 11:29:34 am
@majid.ebru,

4 - 3 and 6-2 - is not necessary.
Then you will automatically get all the downloaded fields.

Michal
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 15, 2017, 11:44:51 am
I rarely do database things. But if I remember correctly, if we do not do the step 6-2, the data won't show on DBGrid on design time.
Title: Re: [SQLite] : i can't see table
Post by: miab3 on May 15, 2017, 12:14:35 pm
@Handoko;

For ZQuery1.Active - True will be visible.

Michal
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 15, 2017, 01:02:55 pm
@majid.ebru,

4 - 3 and 6-2 - is not necessary.
Then you will automatically get all the downloaded fields.

Michal

4 - 3  is  necessary becuase i should change width and name of fildes.

I rarely do database things. But if I remember correctly, if we do not do the step 6-2, the data won't show on DBGrid on design time.

i don't do step 6 - 2  and everything is working correctly

@Handoko;

For ZQuery1.Active - True will be visible.

Michal

No.
i don't change active and visible properties.
Title: Re: [SQLite] : i can't see table
Post by: Handoko on May 15, 2017, 02:04:37 pm
@majid.ebru

I saw you're very diligent, in short period of time you have learned a lot of things.

You should use what you have learned to build some useful tools. For example, you can write a personal notebook program that collects notes like what I made, see the image. It is a tray icon program, it will stay on the taskbar until user clicks it. There you can have several (unlimited) tabs to group the notes. When I found some useful codes or tricks form the Internet, I will copy/paste it to the program. Very useful.
Title: Re: [SQLite] : i can't see table
Post by: majid.ebru on May 15, 2017, 03:29:22 pm
@majid.ebru

I saw you're very diligent, in short period of time you have learned a lot of things.

You should use what you have learned to build some useful tools. For example, you can write a personal notebook program that collects notes like what I made, see the image. It is a tray icon program, it will stay on the taskbar until user clicks it. There you can have several (unlimited) tabs to group the notes. When I found some useful codes or tricks form the Internet, I will copy/paste it to the program. Very useful.

Thanks a lot
.
.
i am  beginner in PC programing and i like programing.
.
last time i want to create android apk and mr. jmpessoa and you , help and guide me to learn and build apk.
.
but now i should build Database application.
.
until now i desgin application and now i should write code.
.
i search internet for find my answer(too) and Lazarus forum is very very very gooooooood.
Title: Re: [SQLite] : i can't see table
Post by: marsupilami79 on May 15, 2017, 09:39:40 pm
Zeos developers take note! Offer option to use system default path for libraries (32 AND 64 bit). Offer option to make path relative.

Hello Thaddy,

you have some good points in your posts. There are a lot of things that could be done better in Zeos. What I really miss are your patches to solve problems and your bugreports? I didn't see you file anything in the Zeos forums or in the bugtracker.

With best regards,

Jan
TinyPortal © 2005-2018