Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from SQL file - feature request #1006

Open
blessedjasonmwanza opened this issue Aug 21, 2021 · 4 comments
Open

Import from SQL file - feature request #1006

blessedjasonmwanza opened this issue Aug 21, 2021 · 4 comments
Labels

Comments

@blessedjasonmwanza
Copy link

Information

  • Version of Medoo: 2.1.2
  • Type of Database (MySQL, MSSQL, SQLite...):
  • System (Liunx\Windows\Mac):

Description

This is a feature request; When you have time, may you kindly add the ability for us to import an SQL file directly into a database?

Detail Code example

$file_location = 'dir/file.sql';
$db_instance->import_sql($file_location);
//or
$db_instance->import_raw($file_location);

Response

Can return true, false or add the error message into the $db->error var

@catfan
Copy link
Owner

catfan commented Aug 22, 2021

With the experience of importing the database file, the better way to do this is to use the SQL command line or other database management tools to ensure the correct result.

@catfan catfan added the idea label Aug 22, 2021
@blessedjasonmwanza
Copy link
Author

blessedjasonmwanza commented Oct 18, 2021

Hey @catfan 🤓 ... I was thinking about this and experimented with something that works.

//First, we load the db file into a variable
$db_sql_file = file_get_contents("db_file.sql");
//then we run query on it to perform whatever instructions are in the SQL file against the database instance we're connected to😄 
$db_instance->query($db_sql_file);

Is this something that can be improved on? You may share your opinion or ideas whenever time allows.

HappyCoding 👨🏽‍💻

@catfan
Copy link
Owner

catfan commented Oct 19, 2021

@blessedjasonmwanza Yes, it can simply work in some cases. However, the result is not guaranteed if with a different setting, database version, platform, or others.

@blessedjasonmwanza
Copy link
Author

@blessedjasonmwanza Yes, it can simply work in some cases. However, the result is not guaranteed if with a different setting, database version, platform, or others.

Oh - I see, 🤔 ... Makes a lot of sense 🤓 . Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants