Jump to content

Sqlite -- Modules, Case Studies or Advise


Davis Harrison Dion
 Share

Recommended Posts

Hello,

We're setting up a PW app that has a dozen sqlite databases it will use for various tasks and analytics.

Does anyone know if there are any modules with any sqlite connectivity in them? I haven't seen any on first glance.

I know this is nebulous, but is there any advise on how to best "fold in" sqlite connectivity AND data into PW's existing structure?

Thanks!

Link to comment
Share on other sites

@Davis Harrison Dion

Hello, whilst there has been sporadic chat in the forums regarding sqlite over the years, I don't think we are any closer to seeing core support for it. I'm also unaware of any third party integration that's using it. 

I'd be delighted if I were wrong about that though; perhaps someone lurking in here does know how it can be done.

  • Like 1
Link to comment
Share on other sites

Note sure if it suits your needs or not, but it's really easy to include https://dibiphp.com/ into PW and then you can query those sqlite databases within your template files / modules.

You can put this in your init.php file:

require_once __DIR__ . '/vendor/autoload.php';
$this->wire("dibi", new Dibi\Connection([
    'driver'   => 'sqlite',
    'host'     => hostname,
    'username' => user,
    'password' => pass,
    'database' => dbname,
]));

and then you can query using the global $dibi variable like this:

$result = $dibi->query('SELECT * FROM mytable');
foreach ($result as $row) {
    echo $row->fieldname;
}

 

  • Like 7
Link to comment
Share on other sites

On 11/24/2020 at 3:03 PM, adrian said:

Note sure if it suits your needs or not, but it's really easy to include https://dibiphp.com/ into PW and then you can query those sqlite databases within your template files / modules.

You can put this in your init.php file:

@adrian This is really neat...thanks for posting!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...