SQLite3 / PDO - No such table though it does exist
up vote
3
down vote
favorite
I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users
. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
php pdo sqlite3
add a comment |
up vote
3
down vote
favorite
I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users
. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
php pdo sqlite3
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users
. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
php pdo sqlite3
I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users
. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
php pdo sqlite3
php pdo sqlite3
edited Oct 15 '14 at 17:20
Mika Tuupola
12.1k53144
12.1k53144
asked Oct 15 '14 at 9:35
Jeahel
103211
103211
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41
add a comment |
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
add a comment |
up vote
0
down vote
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public
directory (should be app
in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update
) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
add a comment |
up vote
5
down vote
accepted
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
answered Oct 15 '14 at 10:23
CL.
134k12120153
134k12120153
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
add a comment |
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
I did not know about the automatic creation of the database, but mine is correct and exists. The app.db file is in the parent folder of the script containing the two lines I pasted. It seems to open it correctly because I have no other app.db file created anywhere.
– Jeahel
Oct 15 '14 at 11:04
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
The evidence shows that the database path you're using is not correct.
– CL.
Oct 15 '14 at 12:19
1
1
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
Well, I just tried with an absolute path to the .db file and it worked. I feel a bit stupid not to have tried this in first... But I wonder, what should be the reference with a relative path? Relative to the PHP script did not work as I tried it, but it surely was a path problem as an absolute path solved the problem. Anyway, thank you!
– Jeahel
Oct 15 '14 at 15:34
2
2
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
A relative path is based on the current directory, which in PHP, is random.
– CL.
Oct 15 '14 at 17:44
add a comment |
up vote
0
down vote
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public
directory (should be app
in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update
) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
add a comment |
up vote
0
down vote
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public
directory (should be app
in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update
) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
add a comment |
up vote
0
down vote
up vote
0
down vote
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public
directory (should be app
in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update
) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public
directory (should be app
in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update
) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
answered Nov 22 at 16:08
gogaz
1,578919
1,578919
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26379145%2fsqlite3-pdo-no-such-table-though-it-does-exist%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't have an answer to your question, but I'd recommend that you try to tag this with some kind of slim framework tag as as the prerequisities for your code snippet needs to be known (and they're probably a part of the slim framework) - so you probably wanna get some answers from people who actually works with the framework : ) My best shot would be that you didn't setup your configuration files correctly though.
– Dencker
Oct 15 '14 at 9:40
Thanks, I did. I thought that it was only related to PDO or SQLite but I am not sure, so...
– Jeahel
Oct 15 '14 at 9:41