{"id":13420810,"url":"https://github.com/toddtreece/lib_mysqludf_mongodb","last_synced_at":"2025-08-28T09:08:37.914Z","repository":{"id":138428624,"uuid":"2558586","full_name":"toddtreece/lib_mysqludf_mongodb","owner":"toddtreece","description":"MySQL UDF for inserting data into MongoDB","archived":false,"fork":false,"pushed_at":"2012-02-03T21:33:28.000Z","size":141,"stargazers_count":16,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T22:56:41.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toddtreece.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-11T21:55:03.000Z","updated_at":"2021-02-14T02:08:09.000Z","dependencies_parsed_at":"2023-03-13T03:02:24.720Z","dependency_job_id":null,"html_url":"https://github.com/toddtreece/lib_mysqludf_mongodb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/toddtreece/lib_mysqludf_mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddtreece%2Flib_mysqludf_mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddtreece%2Flib_mysqludf_mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddtreece%2Flib_mysqludf_mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddtreece%2Flib_mysqludf_mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toddtreece","download_url":"https://codeload.github.com/toddtreece/lib_mysqludf_mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddtreece%2Flib_mysqludf_mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272475100,"owners_count":24940685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:41.857Z","updated_at":"2025-08-28T09:08:37.885Z","avatar_url":"https://github.com/toddtreece.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"# lib_mysqludf_mongodb\n\nlib_mysqludf_mongodb\nCopyright 2011 Todd Treece\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).\n\n## Hunh?\nThe goal of the project is to allow MySQL triggers to store data in MongoDB.  By tracking MySQL changes (inserts/updates/deletes) in MongoDB, backing up system critical data will become faster and easier.\n\n## Requirements\n*  [MongoDB C Driver](http://www.mongodb.org/display/DOCS/C+Language+Center)\n*  libmysql-dev\n\n## Installation\n\n### Tested on Ubuntu Server 10.04.3 LTS x86_64\n* MongoDB version v1.2.2\n* MySQL version 5.1.41-3ubuntu12.10\n* gcc version 4.4.3\n  \n\n### Compiling lib_mysqludf_mongodb\n* Use git to clone the Mongo C Driver repo into /usr/local/lib\n* Complile the latest version of MongoDB C Diver using the instructions provided [here](http://api.mongodb.org/c/current/building.html).  * Do not use v0.4 of the driver as the instructions state. Compile using HEAD. *\n\n- - -\n\n    $ gcc --std=c99 -shared -Wall -fPIC \\\n      -I/usr/include/mysql \\\n      -I/usr/local/lib/mongo-c-driver/src \\\n      /usr/lib/libmongoc.so \\\n      /usr/lib/libbson.so \\\n      server.c \\\n      io.c \\\n      version.c \\\n      encodings.c \\\n      -o lib_mysqludf_mongodb.so\n    $ sudo cp lib_mysqludf_mongodb.so /usr/lib/mysql/plugin/lib_mysqludf_mongodb.so\n    $ sudo service mysql restart\n\n### Registering the UDF functions with MySQL\n    USE mysql;\n    DROP FUNCTION IF EXISTS mongodb_udf_version;\n    DROP FUNCTION IF EXISTS mongodb_connect;\n    DROP FUNCTION IF EXISTS mongodb_disconnect;\n    DROP FUNCTION IF EXISTS mongodb_save;\n\n    CREATE FUNCTION mongodb_udf_version RETURNS STRING SONAME \"lib_mysqludf_mongodb.so\";\n    CREATE FUNCTION mongodb_connect RETURNS STRING SONAME \"lib_mysqludf_mongodb.so\";\n    CREATE FUNCTION mongodb_disconnect RETURNS STRING SONAME \"lib_mysqludf_mongodb.so\";\n    CREATE FUNCTION mongodb_save RETURNS STRING SONAME \"lib_mysqludf_mongodb.so\";\n\n## Usage\n    -- connecting to mongoDB:\n    -- this will only need to be called once\n    -- and can be placed in a mysql startup script.\n    --\n    -- in my.cnf add a line in the [mysqld] block\n    -- that points to your startup script.\n    -- i.e. init-file = /var/lib/mysql/init.sql\n\n    SELECT mongodb_connect(\"127.0.0.1\", 27017);\n\n    -- sample query\n    SELECT mongodb_save('test.customers' AS 'collection', firstname, lastname) FROM customers ORDER BY id DESC LIMIT 0,10;\n\n    -- mongodb insert from mysql trigger sample  --\n    DELIMITER $$\n\n    DROP TRIGGER IF EXISTS mongodb_update_trigger $$\n     \n    CREATE TRIGGER mongodb_update_trigger BEFORE UPDATE ON users\n      \n      FOR EACH ROW BEGIN\n      \n        SET @save = (\n          SELECT mongodb_save(\n            'history.users' AS 'collection',\n            NEW.id AS 'id',\n            NEW.username AS 'username',\n            NEW.firstname AS 'firstname', \n            NEW.lastname  AS 'lastname',\n            NEW.email AS 'email',\n            'update' AS 'history_type',\n            NOW() AS 'timestamp'\n          )\n        );\n     \n      END;\n\n    $$\n\n    DELIMITER ;\n    -- end trigger sample --\n\n\n    -- disconnect from mongoDB\n    SELECT mongodb_disconnect();\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddtreece%2Flib_mysqludf_mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoddtreece%2Flib_mysqludf_mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddtreece%2Flib_mysqludf_mongodb/lists"}