SQLite3 / PDO - No such table though it does exist
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 |
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 |
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.2k53245
12.2k53245
asked Oct 15 '14 at 9:35
JeahelJeahel
118211
118211
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
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 |
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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.CL.
135k13121154
135k13121154
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 |
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 |
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 |
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 '18 at 16:08
gogazgogaz
1,5301021
1,5301021
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.
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