{"id":13562326,"url":"https://github.com/NotCompsky/libcompsky","last_synced_at":"2025-04-03T18:33:23.354Z","repository":{"id":217534113,"uuid":"191913296","full_name":"NotCompsky/libcompsky","owner":"NotCompsky","description":"C++ library used in some of my projects","archived":false,"fork":false,"pushed_at":"2021-08-26T11:56:15.000Z","size":396,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-11-04T14:44:54.424Z","etag":null,"topics":["cpp","library","mysql","qt"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotCompsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-14T09:15:52.000Z","updated_at":"2021-10-15T01:02:12.000Z","dependencies_parsed_at":"2024-01-17T02:52:06.597Z","dependency_job_id":"8d794448-26a6-4a45-8806-c782fa46c8e4","html_url":"https://github.com/NotCompsky/libcompsky","commit_stats":null,"previous_names":["notcompsky/libcompsky"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCompsky%2Flibcompsky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCompsky%2Flibcompsky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCompsky%2Flibcompsky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCompsky%2Flibcompsky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotCompsky","download_url":"https://codeload.github.com/NotCompsky/libcompsky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247057010,"owners_count":20876495,"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","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":["cpp","library","mysql","qt"],"created_at":"2024-08-01T13:01:07.228Z","updated_at":"2025-04-03T18:33:18.343Z","avatar_url":"https://github.com/NotCompsky.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"Platform | CI Status\n---------|----------\nOSX      | [![OSX Build Status](http://badges.herokuapp.com/travis/NotCompsky/libcompsky?env=BADGE=osx\u0026label=build\u0026branch=master)](https://travis-ci.org/NotCompsky/libcompsky)\nLinux    | [![Linux Build Status](http://badges.herokuapp.com/travis/NotCompsky/libcompsky?env=BADGE=linux\u0026label=build\u0026branch=master)](https://travis-ci.org/NotCompsky/libcompsky) [![CircleCI](https://circleci.com/gh/NotCompsky/libcompsky.svg?style=shield)](https://circleci.com/gh/NotCompsky/libcompsky)\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/66dc520c5a27425c8e131f8d9b76b385)](https://www.codacy.com/app/NotCompsky/libcompsky?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=NotCompsky/libcompsky\u0026amp;utm_campaign=Badge_Grade)\n\n## Description\n\nThis package is just a collection of a few bits and bobs used in various projects of mine.\n\n## Installing\n\n### Ubuntu and other Debian-derived systems\n\n    regexp=\"https://github\\.com/NotCompsky/libcompsky/releases/download/[0-9]\\.[0-9]\\.[0-9]/libcompsky-[0-9]+\\.[0-9]+\\.[0-9]+-$(dpkg --print-architecture)\\.deb\"\n    url=$(curl -s https://api.github.com/repos/NotCompsky/libcompsky/releases/latest  |  egrep \"$regexp\" | sed 's%.*\"\\(https://.*\\)\"%\\1%g')\n    wget -O /tmp/libcompsky.deb \"$url\"\n    sudo apt install /tmp/libcompsky.deb\n\nUsers of other Debian-based distributions may have to modify the dependency package names before the packages will install (you could use `equivs` if you don't want to modify the `deb` itself). Send a bug report with your platform and a suggestion for the alternative dependency.\n\nIf installation still fails for some reason, see [installing on Ubuntu](INSTALLING_UBUNTU.md) (and also make a bug report).\n\n### Other\n\nYou should compile from source. But if there's enough interest, I'll distribute Windows installers too.\n\n## mysql\n\nThis is the main feature of the library. It is a wrapper around `libmysqlclient` that - in my opinion - has a far simpler syntax. And presumably far fewer features, although of course you still have access to the underlying `libmysqlclient` functions.\n\nIt uses `asciify` (another part of this project) to format the strings sent to the MySQL server.\n\n### Dependencies\n\n*   libmysqlclient\n\n### Usage Examples\n\n    #include \u003ccompsky/mysql/query.hpp\u003e\n    \n    MYSQL_RES* RES;\n    MYSQL_ROW ROW;\n    \n    compsky::mysql::init(\"/path/to/file.cfg\");\n    \n    compsky::mysql::query(\u0026RES, \"SELECT id, name FROM \",  table,  \" WHERE id \u003c \",  100);\n    \n    uint64_t id;\n    char* name;\n    while(compsky::mysql::assign_next_row(RES, \u0026ROW, \u0026id, \u0026name))\n        std::cout \u003c\u003c +id \u003c\u003c \": \" \u003c\u003c name \u003c\u003c std::endl;\n    \n    compsky::mysql::exit();\n\n\n`init` and `exit` are a pair, and entirely optional - you can just connect directly via `libmysqlclient`. However, if used, the config file must have exactly the correct syntax.\n\nFor convenience, `compsky_mysql_create_config` provides a way to make very simple programs to initialise the database, its tables, and its config file for you, for a given project:\n\n    #include \u003ccompsky/mysql/create_config.hpp\u003e\n    \n    int main(){\n        compsky::mysql::create_config(\n            #include \"init.sql\"\n            , \"PROJECT_MYSQL_CFG_PATH\"\n        );\n        return 0;\n    }\n\nHere `init.sql` is a file next to the source file that only contains the SQL commands to create tables, in a raw string.\n\n## asciify\n\n### Benchmarks\n\nUsing [libfmt's benchmark](https://github.com/fmtlib/format-benchmark) patched to include `compsky::asciify`, I get the following results on my machine (Intel Ubuntu 18.04):\n\n| real             | user | sys  |\n| -                | -    | -    |\n| printf           | 1.07 | 1.06 |\n| iostreams        | 1.76 | 1.76 |\n| format           | 1.01 | 1.01 |\n| fmt::prepare     | 0.93 | 0.86 |\n| tinyformat       | 2.17 | 2.16 |\n| boost            | 6.19 | 6.18 |\n| compsky::asciify | 0.32 | 0.31 |\n| folly            | N/A  | N/A  |\n| stb_sprintf      | 0.68 | 0.68 |\n\nThis benchmark is just to satisfy curiosity. I don't think `compsky::asciify` is particularly useful to anyone - if you look at the output, you can see that the floats are not printed exactly, with `1.2339999999` instead of `1.2340000000` and (more worryingly) `3.12` instead of `+3.13`. Perhaps this is something that can be fixed, but I would expect many other flaws exist, and suggest that `compsky::asciify` is only useful where both a *nearly* correct answer is acceptable and performance is critical and you have a relatively new compiler (i.e. almost never).\n\nYou can test it yourself using [the patch](3rdparty/patches/format-benchmark/0001-Added-compsky-asciify.patch) and applying it in the `format-benchmark` directory with `git am \u003c /PATH/TO/0001-Added-compsky-asciify.patch`).\n\n## security\n\nContains the `memzero_secure` function based on the work of `Zhaomo Yang` that he released into the Public Domain. It is used to wipe `mysql` authentification details when `compsky::mysql::exit()` is called.\n\n## Building\n\n### Unix\n\n    git clone https://github.com/NotCompsky/libcompsky\n    cd libcompsky\n    mkdir build\n    cd build\n    cmake ..\n    sudo cmake install\n\n### Windows\n\n#### Cross Compiling from Linux\n\nYou must use MXE, as the standard MinGW tools on Ubuntu do not include things such as libmysqlclient. If you haven't installed it already, allocate an hour or so (and ~3GB) for it to download and build all dependencies.\n\n    git clone https://github.com/mxe/mxe\n    cd mxe\n    make MXE_TARGETS=x86_64-w64-mingw32.static\n    make libmysqlclient\n\nEnsure MXE's `/usr/bin` is in your `PATH`:\n\n    export PATH=\"$PATH:$PWD/usr/bin\"\n\nNow build libcompsky:\n\n    cd ..\n    git clone https://github.com/compsky/libcompsky\n    cd libcompsky\n    mkdir build\n    cd build\n    x86_64-w64-mingw32.static-cmake ..\n    make\n    sudo make install\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNotCompsky%2Flibcompsky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNotCompsky%2Flibcompsky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNotCompsky%2Flibcompsky/lists"}