Help, read a CSV table or database

Multimedia Builder (Legacy Forum)
Post Reply
rikintosh
Posts: 16
Joined: Sun Aug 06, 2017 6:58 pm

Help, read a CSV table or database

Post by rikintosh »

I need to read a lot of information, which should be in a spreadsheet or database. For example, name, type, quantity .... Each of the fields, will replace a Text or go to a variable

Could someone help me find a way for MMB to read a csv or a database?

Nigg
Posts: 74
Joined: Thu Apr 14, 2011 2:10 pm

Re: Help, read a CSV table or database

Post by Nigg »

SQLite works very well. The queries can be written normally with SQL and the output, well, there are different approaches. HTML output would certainly be possible as well. What exactly should be done with it then?

rikintosh
Posts: 16
Joined: Sun Aug 06, 2017 6:58 pm

Re: Help, read a CSV table or database

Post by rikintosh »

Hi Nigg, thanks for answering me.

I'm doing a frontend / game manager. I created a database / spreadsheet that contains the name of the game, producer, year, rating, etc ... I will use my mmb project to extract this information, and place it in text fields.

Image


Taking advantage of the subject, I have a doubt as a beginner, it is something so silly that I am ashamed to ask lol

In the query, for example, I want to get the contents of the column "NAME", line / id / key "3", it is a single result (no columns and rows full of results) how do I request this in SQL? I tried SELECT ID, NAME FROM Table when id = `3´, but I get an error

Nigg
Posts: 74
Joined: Thu Apr 14, 2011 2:10 pm

Re: Help, read a CSV table or database

Post by Nigg »

Looks interesting. It is definitely possible. Only with the graphics you might run into one or the other barrier. The SQL syntax is pretty expressive. In your case the "when" is wrong and must be "where".

You can use this tool here to design your database and try out the queries:

https://sqlitebrowser.org/blog/portable ... available/

Code: Select all

SELECT name FROM table WHERE id = 3
If you want my advice, design the database a little more thoughtfully:

Code: Select all

SELECT game_name FROM games WHERE game_id = 3
Maybe you realize later that you need another table called e.g. "Genre". Then it pays off.

Some MMB example code:

Code: Select all

SQL$ = 'SELECT game_id, game_name, game_rating, game_release, game_publisher FROM games;'
***
PluginSet("dbdrv","SQL$")
PluginRun("dbdrv","Query")
PluginGet("dbdrv","Results$")
PluginGet("dbdrv","Rows")
PluginRun("dbdrv","DBError")
PluginGet("dbdrv","DBError$")
If (DBError$='') Then
  Delimiter$ = '#'
  For i=1 To Rows
    Rows$[i] = GetArrayItem(Results$,Delimiter$,i)
    Rows$[i] = Rows$[i] + '|'
    NumberOfFields = GetArrayNum(Rows$[i],|)
    ***
    game_id$ = GetArrayItem(Rows$[i],|,1)
    game_name$ = GetArrayItem(Rows$[i],|,2)
    game_rating$ = GetArrayItem(Rows$[i],|,3)
    game_release$ = GetArrayItem(Rows$[i],|,4)
    game_publisher$ = GetArrayItem(Rows$[i],|,5)
  Next i
  ***
Else
  Message("","error_dbcritial$")
  Exit()
End

rikintosh
Posts: 16
Joined: Sun Aug 06, 2017 6:58 pm

Re: Help, read a CSV table or database

Post by rikintosh »

sorry for looking stupid, but i have a little dyslexia so i have difficulty with some things. I was able to read the data from my db, my problem now is that I don't know how to list the names in the listbox, and when I click on the name, it displays the data, could you help me with an example? I will be able to continue to develop from a single example as I am better at modifying things than creating them from scratch I have attached a simple sketch of my project with my database, all that remains is to make the listbox work
Attachments
media1.zip
(203.36 KiB) Downloaded 14 times

Post Reply