Author Topic: mySQL & QB64  (Read 2444 times)

0 Members and 1 Guest are viewing this topic.

Offline AtomicSlaughter

  • Newbie
  • Posts: 14
    • View Profile
mySQL & QB64
« on: April 18, 2021, 03:45:45 pm »
OK, so i have been experimenting with mySQL and QB64 under Linux (Ubuntu 20.04) and here is what i have discovered.

Using Pipecom by SpriggsySpriggs, I have been able to impliment a rudimentary mySQL interface

Here is the code for creating and adding to the database
Code: QB64: [Select]
  1. Shell "echo 'CREATE DATABASE epos' | mysql -uroot"
  2. Shell "echo 'CREATE TABLE plu (item CHAR(20), price CHAR(20), grp CHAR(20), tax CHAR(20), kit CHAR(20))' | mysql -uroot epos"
  3.  
  4.     Input "item>   ", item$
  5.     Input "price>  ", price$
  6.     Input "group>  ", grp$
  7.     Input "tax>    ", tax$
  8.     Input "kitchen ", kit$
  9.     Print ""
  10.     Shell "echo " + Chr$(34) + "INSERT INTO plu (item, price, grp, tax, kit) VALUES ('" + item$ + "', " + price$ + ", " + grp$ + ", " + tax$ + ", " + kit$ + ")" + Chr$(34) + " | mysql -uroot epos"
  11.  
  12.  
  13. '$INCLUDE:'pipecom.bas'

And here is the code for reading the data back
Code: QB64: [Select]
  1.     price_search
  2.  
  3. Sub price_search
  4.     Cls
  5.     Print "price search"
  6.     Input "Enter item Name >", q$
  7.     query$ = pipecom_lite("echo " + Chr$(34) + "SELECT price FROM plu WHERE item = '" + q$ + "'" + Chr$(34) + " | mysql -uroot epos -s")
  8.     Print "the price of " + q$ + " is " + query$
  9.     q$ = ""
  10.     query$ = ""
  11.     _Delay 2
  12.  
  13. '$INCLUDE:'pipecom.bas'

Not sure if this is useful to anyone but here it is anyway

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: mySQL & QB64
« Reply #1 on: April 22, 2021, 03:03:20 pm »
Interesting!  I'll save this for a future use or idea, thanks!