DOS Complied Program to access MySQL Server

DOS specific questions.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: DOS Complied Program to access MySQL Server

Post by exagonx »

Gablea wrote:I emailed MySQL and they did confirm that they had a dos library for MySQL but they lost it a few years ago when it was deleted from their archives.

They did say I could make my own library but I would be on my own as they do not support dos any more.

The Linux interface works a treat I just wish I could get the dos machines to work the same way.

Maybe I am asking to much of dos in this project.
I give more details:

libmysqlclient.lib (DOS Library connector for CPP) Work from DOS 7.xx and later because the older version doesn't have a 32Bit protected area.

Anyway you cant use it , you not have enough memory, CPU is 16Bit and you need 32bit CPU (Intel 386DX or Higher )
The one think you can its only one:
Use like terminal with telnet client , Make a good program with freebasic , let him work under command line with simple text GUI, that make a sistem stable, fast, and with good efficency.
Until the hardware change I Dont know a better way.

I can give you a source for a simple function with FreeBASIC for work with MySQL Server ( the code work in Windows and Linux too without modify )
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: DOS Complied Program to access MySQL Server

Post by caseih »

There's another possible solution for you Gablea. If you abstract out all of the SQL stuff from your POS code and put all that on the Linux server and call it over some kind of RPC mechanism. As long as you have TCP/IP on DOS, you could do this. Instead of making an SQL connection and an SQL query, your POS code would connect to a little server engine you run on the Linux server, and ask it to do the query for you. Basically RPC. This is actually a very common architecture in the world of enterprise software, since you really don't want raw SQL going on the Internet. Instead they make remote procedure calls over something like HTTPS to the business logic layer which in turn talks to the database which would be behind the firewall with it. It's safer and it also gives you more flexibility to replace the backend SQL server with something else later, without having to change the code on the front-end machines.

There is a C library I've used in the past called xmlrpc-c, which makes it pretty easy to export functions as services, and to call them. Could be used from FB. There are other standards as well, including SOAP. You'd have to build DOS versions of any of these libraries yourself, though, and get them to link against the djgpp watt32 TCP/IP stack. But it's doable, and probably a touch easier than working with libmysql on MSDOS.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: DOS Complied Program to access MySQL Server

Post by exagonx »

caseih wrote: and probably a touch easier than working with libmysql on MSDOS.
This is my function for work with libmysqlclient

Code: Select all

#Include Once "mysql\mysql.bi"
#define NULL 0

    Dim Shared URLServer As String
    Dim Shared SVRDataBase As String
    Dim Shared SVRUser As String
    Dim Shared SVRPassword As String

    DIM Shared Conn As MYSQL PTR
    DIM Shared MySQLOut As MYSQL_RES PTR
    DIM Shared Row As MYSQL_ROW

Declare Function MySQLRead(MyQuery As String, MyWork As String) As Integer    

    Dim Shared MyQuery As String
    URLServer = "localhost"
    SVRDataBase = "test"
    SVRUser = "donalduck"
    SVRPassword = "mickey"

Function MySQLRead(MyQuery As String, MyWork As String) As Integer    
	Dim Errore as Integer

    Conn = mysql_init(NULL)
	
    if (Conn = 0) then Errore = 0
    if mysql_real_connect(Conn, URLServer, SVRUser, SVRPassword, SVRDataBase, 0, NULL, 0) = NULL then Errore = 0
    if mysql_query(Conn, MyQuery) then Errore = 0

    MySQLOut = mysql_store_result(Conn)

    if MySQLOut = 0 then Errore = 0
    Return Errore
   
End Function 


Sub Reading()
    DIM TotalCol As Integer
    DIM TotalRow As Integer
    Dim CiR As Integer
    Dim CiC As Integer
    Dim NE as Integer
    
    
    IF MySQLRead("SELECT * FROM `cape_anagrafica`", "read") = 0 then Print "Errore"
    
    TotalCol = mysql_num_fields(MySQLOut)
    TotalRow = mysql_num_rows(MySQLOut)
    
	print TotalRow
	
	For CiR = 0 to TotalRow -1 step 1
	Row = mysql_fetch_row(MySQLOut)
		For Cic = 0 To TotalCol - 1 step 1
			if Row[CiC] = NULL then print "| NULL "; else print "| "; *Row[CiC]
		Next CiC
	Next Cir

    mysql_free_result(MySQLOut)
    mysql_close(Conn)
End Sub

Reading()
You can manage like you want , and can use the normal mysql query like PHP
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: DOS Complied Program to access MySQL Server

Post by caseih »

Right but what I'm talking about is taking something like the code you wrote and sticking it on a Linux server (maybe the same server as MySQL is running on) but wrap your function in an exporter that lets him call your function (or something like it) over the network via some form of RPC such as XMLRPC or SOAP or something else.

In fact, with something like XMLRPC, you could write the functions that actually talk to SQL in any language including PHP on apache. As much as I loath PHP, this might actually be his best bet.
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: DOS Complied Program to access MySQL Server

Post by Gablea »

are you guys saying there is a dos version of the my sql library that i could use on my i386 terminals? where do i find this library?? as
that would fix my problems as the customer wants faster machines but they still want DOS (and Yes I like dos when it does one thing
like running a PoS application)

I assume it would not be the same library as what i am using at the moment in linux and windows.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: DOS Complied Program to access MySQL Server

Post by caseih »

I think exagonx simply misunderstood much of what I was saying. Other than what you mentioned about an old library the they used to maintain, none of us knows of any precompiled libmysqlclient library for MS DOS. With significant effort, I believe libmysqlclient could be ported to DJGPP compiler and some socket library (see below).

No matter how you cut it, it will be significant work to port relevant things to MSDOS. If you go the RPC route, you'd still have to get TCP/IP working on MS DOS, and get a working sockets library (for example, http://www.watt-32.net/), and then port the xmlrpc library over to MS DOS using djgpp.

Personally I'd rather put my effort into getting xmlrpc between MSDOS clients and a Linux-based business logic system that would abstract your database calls and do the SQL stuff on behalf of the client and not use raw SQL between the DOS clients and the Linux MySQL server.
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: DOS Complied Program to access MySQL Server

Post by Gablea »

I think we have hit a limit of what DOS can handle.

I have TCP/IP working on the dos i386 machine as I can ping the database server but as it is i386 I may as well get the client to move the i386 price checking machines into Debian 8.5 and not use a desktop on them (so they look like dos running)
Last edited by Gablea on Aug 08, 2016 23:14, edited 1 time in total.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: DOS Complied Program to access MySQL Server

Post by exagonx »

caseih wrote:I think exagonx simply misunderstood much of what I was saying.
Maybe,

I think is better make a software for server side and let work with power of the server and not lose time and resorce for implement a library for obsolete architecture , the new tecnology going for 64 bit and 128 bit, and we talking how find a way to work with a old machine.

caseih you are right implement xmlrpc is a good way for make a client compatible with most server, but a old machine is old machine and at last Is like play to tetris , you have a little space and to much work to do.

anyway apologies if I got a wrong idea about what you writed, I have a little proble with english expecially if is used a slang .
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: DOS Complied Program to access MySQL Server

Post by caseih »

I see. You're correct of course, and that was also the same course of action I recommended. Guess I misunderstood you. Gablea apparently read what you wrote and understood that to mean you had a working libmysqlclient on MSDOS.
Post Reply