Migration from MySQL and PostgreSQL: Difference between revisions

From MemCP
Jump to navigation Jump to search
(Created page with "thumb|none|640x640px ===Connection to MemCP via MySQL Connector=== MemCP can be connected with any compatible MySQL connector: $db = new \PDO<code>"mysql:host=localhost;port=3307;dbname=system", 'root', 'admin');</code> echo $db->query("SELECT 'it works'")->fetchColumn(); // outouts: it works ===Import data from MySQL and PostgreSQL=== To import data from MySQL into MemCP, you have to perform the following command in<code>memcp</code>console: (l...")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
 
 
// outouts: it works
 
// outouts: it works
  +
  +
=== Connection to MemCP from PostgreSQL ===
  +
For postgresql, just switch over to a mysql connector (odbc and PDO both support multiple databases) and send<code>SET syntax = 'postgresql'</code>at the very beginning of your session
  +
  +
Or, switch over to the [[SQL over REST|REST connector]].
  +
 
===Import data from MySQL and PostgreSQL===
 
===Import data from MySQL and PostgreSQL===
To import data from MySQL into MemCP, you have to perform the following command in<code>memcp</code>console:
+
To import data from MySQL into MemCP, you have to perform the following command in[[MemCP Console|<code>memcp</code>console]]:
 
(load_sql "database" (stream "dump.sql")) /* for PostgreSQL mode, use load_psql instead */
 
(load_sql "database" (stream "dump.sql")) /* for PostgreSQL mode, use load_psql instead */
 
When the sqldump is zipped, use:
 
When the sqldump is zipped, use:
Line 14: Line 20:
 
(load_sql "database" (xz (stream "dump.sql"))) /* for PostgreSQL mode, use load_psql instead */
 
(load_sql "database" (xz (stream "dump.sql"))) /* for PostgreSQL mode, use load_psql instead */
 
The dumps can be created with <code>mysqldump</code>or <code>pg_dump</code>.
 
The dumps can be created with <code>mysqldump</code>or <code>pg_dump</code>.
  +
  +
=== Further Reading ===
  +
  +
* [[Deployment]]

Latest revision as of 19:33, 20 November 2024

Ports.svg

Connection to MemCP via MySQL Connector

MemCP can be connected with any compatible MySQL connector:

$db = new \PDO"mysql:host=localhost;port=3307;dbname=system", 'root', 'admin');
echo $db->query("SELECT 'it works'")->fetchColumn();

// outouts: it works

Connection to MemCP from PostgreSQL

For postgresql, just switch over to a mysql connector (odbc and PDO both support multiple databases) and sendSET syntax = 'postgresql'at the very beginning of your session

Or, switch over to the REST connector.

Import data from MySQL and PostgreSQL

To import data from MySQL into MemCP, you have to perform the following command inmemcpconsole:

(load_sql "database" (stream "dump.sql")) /* for PostgreSQL mode, use load_psql instead */

When the sqldump is zipped, use:

(load_sql "database" (gzip (stream "dump.sql"))) /* for PostgreSQL mode, use load_psql instead */

or:

(load_sql "database" (xz (stream "dump.sql"))) /* for PostgreSQL mode, use load_psql instead */

The dumps can be created with mysqldumpor pg_dump.

Further Reading