Trying to make code work with SQLite

QuestionsTrying to make code work with SQLite
Mox asked 3 years ago

I have a database moja.db created with DB Browser for SQLite.

I created gridtest.php with code:

I get message Please check your database connection configuration. Connection attempt failed: SQLSTATE[HY000] [14] unable to open database file

What do I have to do to make it work?

2 Answers
Mox answered 3 years ago

Sorry, code didnt displayed in previouse message.

<?php
$db_conf = array();
$db_conf[“type”] = “pdo”; // mysql,oci8(for oracle),mssql,postgres,sybase
$db_conf[“server”] = “sqlite:moja.db”;
$db_conf[“user”] = “”;
$db_conf[“password”] = “”;
$db_conf[“database”] = “moja”;
?>

Abu Ghufran Staff answered 3 years ago

If your database and grid code file reside in same folder, try

$db_conf[“server”] = “sqlite:./moja.db”;

Added ./ before moja.db.

You can also refer working demo:

Code:
https://www.gridphp.com/demo/demos/loading/db-layer-sqlite.phps
Demo: https://www.gridphp.com/demo/demos/loading/db-layer-sqlite.php

 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff replied 3 years ago

You don’t need to set db. Make it blank.
$db_conf[“database”] = “”;

Your Answer

11 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?