[Class] SQLiteDB - Update on 2022-10-04

Post your working scripts, libraries and tools for AHK v1.1 and older
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

08 Mar 2019, 13:58

currently I'm testing it, but.. got nothing.
actually, I do not know how to use it.


Just for reference.

my DB Link
https://drive.google.com/file/d/1DQ_zDk9A1IeGUHsmSLWeCS5-6JSWkqrV/view?usp=sharing

the name of table is: "translation_units"
the names of two columns I'm interested in are : "source_segment", "target_segment"
it has only 3 items within it. "One/Red", "Two/Green", "Three/Blue" (respectively)
- it has its fields as a XML structure, that is why I have to use RegExp all the time.

How can I extract "Red" or "Three" items using Functions ?
(I am not mentioning XML element values, but field as a whole. I can handle XML animals properly)

I have tried query like this;
"SELECT * FROM translation_units WHERE target_segment REGEXP 'Three';"

Thanks.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

08 Mar 2019, 21:03

you are using 3 'Name's;
regexp
RegExp
REGEXP

These three of them are the same one or not ?
These three of them are 'Built_In' or not ?

It is quite confusing.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] SQLiteDB - Update on 2016-03-28

08 Mar 2019, 22:11

The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If an application-defined SQL function named "regexp" is added at run-time, then the "X REGEXP Y" operator will be implemented as a call to "regexp(Y,X)".

Source: The LIKE, GLOB, REGEXP, and MATCH operators
I.e.: regexp(Y,X) must be implemented as an application-defined user function. You have to write it completely on your own.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 00:45

hmmm..
Good
I will google it further.
Thanks
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 00:54

my conclusion : no it is not working I do not know how to use it (guess, I have problem with argument of "SQLite3_RegExp" function. But, I do not know how to solve it)

[Note]
1. it could be working, if someone who knows well this kind of work tested it.
2. and, If so. It still needs 'Custom Function' not an operator REGEXP. Think about it, If AHK does not have 'Custom Function'. Then I call it 'UseLess' of course. Simple 'REGEXP' operation is much limited.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 03:17

1. it could be working, ...
Yes.
It still needs 'Custom Function' not an operator REGEXP.
You can use the REGEXP operator only after you implemented the regexp() function.
If AHK does not have 'Custom Function'. Then I call it 'UseLess' of course.
SQLite access functions are not built-in, so why should SQLite custom functions? AHK is able to access SQlite databases via the C/C++-API and AHK is able to implement (simple) SQLite user functions. So what?
Simple 'REGEXP' operation is much limited.
:roll:
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 03:45

Nice reply.
Then How can I implement regexp() function?
I have followed your guide-perfectly- but have failed to achieve it.

Can you show me one working example ?

Regards
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 03:48

What did you try?
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 05:53

Good

I give it up.
I have already spent lots of time and energy to implement basic SQLITE functionality under AHK hood.

You have nice knowledge about it.
Enjoy it.

Regards

ALL of the SQLITE functionality that I needed was implemented using C# (I have included ALL RegeExp and custom functions).
I am using AHK because it is very easy to use and maintain my codes.
But, for SQLITE, AHK is useless. Amazingly.

Do I have to learn C/C++ API ? for AHK_SQLITE ? No, that is a bad idea.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 06:50

@jus me, you’ve done enough here. What you provided was more than enough of a start. Thanks for the great info. It may certainly come in handy for me.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 08:10

IMEime wrote:
09 Mar 2019, 05:53
ALL of the SQLITE functionality that I needed was implemented using C# (I have included ALL RegeExp and custom functions).
It would be interesting to see how you did it in C#. And to know, why you don't understand the meaning of the regexp() custom function's parameters, then.
But, for SQLITE, AHK is useless. Amazingly.
If so, don't use it.
Do I have to learn C/C++ API ? for AHK_SQLITE ? No, that is a bad idea.
What's bad with this idea? SQLite provides a nice documentation and the class contains many examples how to call the functions from AHK.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 09:58

@just me

I am not asking YOU nothing here.
I am just telling YOU that your post has to have "custom functionality"
Without it, your post is useless.
You do not understand it.

As I said ,
You have nice knowledge about SQLITE, C and C++.
And, Clearly, you are enjoying it.
Good for you.

Unfortunately, I do not have any kind of knowledge about C and C++.
But, Fortunately enough, I have finished ALL my SQLITE works within C# - only using the sole language C# (Of course, SQLITE knowledge too).
At there, nobody has twisted my arms to look up C/C++ language documentation.
Because, C# is different from C and C++.

AHK is supposed to familiar with beginner.
You can find it at its first page of its Web ; "... for beginners... beginner friendly... easily create... has never been easier..."
You have a bad idea that AHK users have to know C/C++.
AHK is different from C and C++.

I know you have made very nice post here.
But, you can make your post lot better, if you supported custom functionality too.

Regards
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 10:15

Wow... thanks to you interesting.

I am adding several lines using which I have successfully/perfectly achieved my SQLITE goals without knowing anything about C/C++ at all

First part is THE "Custom Function"

Code: Select all

[SQLiteFunction(Name = "myFunction", Arguments = 2, FuncType = FunctionType.Scalar)]    
public class myFunctionClass : SQLiteFunction
{
	public override object Invoke(object[] args)
	{
		return Regex.Replace(Convert.ToString(args[0]), Convert.ToString(args[1]), "${1}", RegexOptions.Singleline).ToLower();		
	}
}
Second part is a simple query

Code: Select all

"SELECT * FROM translation_units WHERE " + "myFunction(source_segment, '" + myPattern1 + "') == " + "myFunction(target_segment, '" + myPattern2 + "') ";

I guess these two parts are good enough to satisfy your wondering.
Again, You do not needed to have any kind of C/C++ knowledges here.


Regards
Last edited by IMEime on 09 Mar 2019, 10:30, edited 1 time in total.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 10:24

Ok, IMEime, I think you’re done here. Thanks and please move along.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 10:32

@kczx3

Kongrats
from now on
I do not have to see your post
You are blocked from my screen !!!

>kczx3, who is currently on your ignore list, made this post. <-- this is current my screen, you are my new "foe" !!!

Regards
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: [Class] SQLiteDB - Update on 2016-03-28

09 Mar 2019, 11:35

ah

as I said
I have quit
I am not coming back here again

as YOU said, I do/will not use your code.
deleted all of them already.

Good Luck To You
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] SQLiteDB - Update on 2016-03-28

10 Mar 2019, 04:05

IMEime wrote:
09 Mar 2019, 10:15
I am adding several lines using which I have successfully/perfectly achieved my SQLITE goals without knowing anything about C/C++ at all
First part is THE "Custom Function"
...
I guess these two parts are good enough to satisfy your wondering.
Again, You do not needed to have any kind of C/C++ knowledges here.
But you need some kind of C# knowledge there. :roll: I don't know C#, but some kind of 'native' SQLite support seems to be provided by the System.Data.SQlite 'package'.

IMEime wrote:My question is very simple and natural for this kind of section and post.

I would like to know How to use custom functions.

OK ?
You should know it now.

I don't think that Class_SQLite.ahk is useless. You are just unable to solve your task using it as is or to implement the additional function you need.

Good luck to you, too!
Last edited by just me on 10 Mar 2019, 17:01, edited 1 time in total.
DRocks
Posts: 565
Joined: 08 May 2018, 10:20

Re: [Class] SQLiteDB - Update on 2016-03-28

10 Mar 2019, 09:10

Man I feel bad that such insult is given to someone that GAVE a way to use SQLite more easily than starting from scratch... dude man respect the one who provided it for you.
Thats nonsense that you kind of tell him his work is useless.. you should start from scratch and do the work he has already done maybe you would then understand better. Whats bad about the way you talk shit to him is that these kind of things make people bitter and not want to share any more of their good works so please reconsider your positions...
thank you and I know Im not a moderator but common sense made me want to reply.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: [Class] SQLiteDB - Update on 2016-03-28

15 Mar 2019, 19:23

if it possible to use multiple instr ?

Right now part of my statement is

WHERE instr(fname, 'will')

What if I want to do multiples, like WHERE instr(fname, 'will' or 'jim')

Any ideas on this?
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [Class] SQLiteDB - Update on 2016-03-28

15 Mar 2019, 20:28

WHERE instr(frame, “will”) or instr(flame, “Jim”)

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 139 guests