How to connect a database to a table in Grav

For a client I need to know the following:
There are tables on certain pages that need to be automatically filled and updated with data from a MySQL database. I have installed the Database and Views plugin. I have no clue how to connect the tables with the database. I am a front end designer… Could somebody help me? If this is not possible the client’s choice for a CMS will be Drupal 8 :frowning: .

Didn’t have to deal with DBs on Grav, but I’m afraid you still might have to do some coding. To get your connection. Also might find this article useful.

Thanks Karmalakas. I am not afraid of the coding, but i need to know what code and where to put it…

The article looks very promising!!! Thanks

What I understand from the docs, you’d need to create a plugin, that would connect to your DB by using $this->grav['database'], which is initiated by Database plugin. Also in your plugin you probably could do most of the logic that is described in that article I posted

Making a plugin! I will try. Never done that before…

I might try to write a plugin actually later. Sounds interesting and might be challenging :slight_smile:

@TonHaarmans,
as @Karmalakas already stated, you will need to create a plugin that can connect to a mysql database - be aware that the database plugin that was mentioned only can connect to a sqlite DB.
for mysql, you will probably need symfony/doctrine.

@Karmalakas ,
that would be a cool plugin, much appreciated by many users, IMHO :smiley:

Well, at least by me and my client!

Isn’t PDO enough? I thought it was :confused:

So the point would be for me: how to make the connection between the DB and a page or part of a page (like a table width different data in different table cells).

@Karmalakas ,
I think, just PDO itself is not enough, as this is just a wrapper, at least PDO_MYSQL driver will be necessary in this case.
this is also the reason why I proposed to use symfony/doctrine, which would probably be easier to integrate in Grav (not sure, never done that).

In fact, to fill and update from an Excel sheet would be enough…

Databases are so much easier :slight_smile: And I mean SO SO MUCH easier :smiley: Parsing Excel sheets is a pain… Been there, done that :smiley:

hm, if your data is in an excel sheet, why not just save that as csv and import that in grav via table importer plugin ?

yes, parsing excel sheets directly is a PITA :smiley:

Also when saved as CSV?

no, importing csv should be easy.

CSV is a different story :slight_smile: These are fine
As @hoernerfranz mentioned, you could try that plugin in CSV case

Yes, will try that!
The main Database of my client is written in Access. This can spit out a csv, which can be uploaded and then imported into Grav. If that can work, that would be awesome.