using mysql in lua script - mysql

I need to read a database table from inside a Lua script in pdns-recursor on a Scientific Linux 6.4 server which comes with Lua pre-loaded.
Apparently I have to use luarocks to install luasql. When I attempt to install luasql I get:
Checking Lua includes... lua.h not found
lua.h is not on the server.
I tried removing the installed version so I could install from binary but then that trashed the system which apparently uses the installed Lua for everything (yum, rpm, etc). Now I have to reload OS. How can I get MySQL access from embedded Lua?
Thanks in advance.

I assume that you have already checked yum to see if luasql is available through that; if not, you should first do that, and install it through yum if possible.
The immediate cause of the problem you're having is that luarocks automatically builds modules from source, which requires access to the lua headers. These are not needed simply to run programs that use Lua, so they are not installed as part of the normal Lua package. I'm not familiar with Scientific Linux, but you can probably get them by installing a package named lua-dev, lua-devel, lua-headers, or some variant thereof. You may also need the mySQL packages (both the libraries proper and the headers). Once you have those installed, give it another try.
You might also try LuaDist, which I find to be generally more polished than luarocks, and capable of automatically downloading more dependencies; in particular it probably will not require the lua headers installed, and can handle automatically downloading and installing lua itself from source. It does, however, require CMake installed.
If for some reason you can't install the required headers and can't get luarocks or luadist working, you can try downloading and building luaSQL by hand. The Lua headers can be found in the Lua 5.1 source package and LuaSQL 2.2. Assuming the Scientific Linux maintainers haven't excessively customized the version of lua they ship with it, the results should be compatible with the system Lua install.

Related

Mysql Connector 8.0 and Python 3.8

I am using Windows 10. I have python 3.8.2 32 bit installed. I am trying to use mysql-installer-web-community-8.0.20.0.msi the connector for Python. The connectors are grayed out and not available. The error message says Python 32-bit not installed. I see old threads claiming you need Python 3.4. The documentation here: https://dev.mysql.com/doc/connector-python/en/connector-python-versions.html claims this will work with Python 3.8.2. Do I need a different MySql installer? If not, what am I doing wrong?
Thanks,
Scott
I am not sure why I was using the MySQL installer to install libraries for Python. In hind-sight, that doesn't make sense. Use pip to install the drivers like
$ pip install mysql-connector-python
# or
$ python pip install mysql-connector
# or for >= Python 3.9
$ pip install mysqlclient
It is not entirely clear what the difference is, but, the first of the three solved the problem.
I faced similar issue while working with MySQL 8.0.18 with Python 3.8 on Windows 10 64 Bit Machine.
And I used the following workaround -
Ensured that all the installers used were 64-Bits installers for My SQL and Python since my machine is Windows 10 64-bit machine.
Ensured that Python Connector for MySQL supported the corresponding python version from https://insidemysql.com/category/mysql-development/connectors/python/ Incase of issues or lack of information downgraded MySql by minor version.
Downloaded independent MSI for Connector from - dev.mysql.com/downloads
Manually installed the downloaded Connector MSI.
Hopefully this information will help you troubleshoot your issue as well by using corresponding 32-bit versions.
If your CPU architecture is 64 bit then be sure that you download MySQL Connector 64 bit version. 32 bit installers would also work but sometimes occurs minor errors. Also MySQL Connector Python requires Python to be in the system’s PATH. Installation fails if python cannot be located. Add python.exe path to System PATH varible. So that MySQL connector can find the execution file.
It is sadly known that MYSQL has low compatibility with python.
For example, I have stepped into this issue while trying to install mysql-python (a terrible one!) and this other issue while using mysqlclient.
There are a lot of python connectors for mysql, you can try some and see one by one if they work. I would recommend pymysql.
However, I would recommend you to use a Postgresql db with python, it really works like charm, and if you want to have a local DBMS/GUI/workbench to work on it, you can use PgAdmin.
I am not sure why I was using the MySQL installer to install libraries for Python. In hind-sight, that doesn't make sense. Use pip to install the drivers like
$ pip install mysql-connector-python
# or
$ python pip install mysql-connector
It is not entirely clear what the difference is, but, the first of the two solved the problem.
Adarsh

MySQL install from site vs Package manager/BREW MySQL

I was wondering why would anyone want to install MySQL via something like BREW or a package manager instead of going to http://www.mysql.com/downloads/ and just downloading the entire installer?
Is there any benefits or time saving capabilities when I install my local MYSQL setup via BREW?
Vs. using the site:
Using brew or your package manager saves you the time (you don't have to hunt around for a download on the site).
The site can deliver the software in one of many unpredictable ways (e.g., as anything from a script that installs things via your package manager or compiles from in situ resources), including ways that disrupt dependencies of other installed software (which is why installing via package manager is safer and why installing things in this way, around the package manager, should be avoided unless necessary).
Vs. your ordinary package manager:
brew doesn't need sudo; it doesn't write new software versions over old software versions on the system or break system dependencies. Indeed, one of brew's perks is installation into user-specific directories and version-specific subdirectories. You can think of it as a more flexible, power-usery version of the package manager.
brew can install things not packaged by your distro or newer versions of those things than are packages by your distro.
brew is also cross-platform (works on Windows, Linux, and macOS).

Can't open MySQL Utilities

Trying to open MySQL Utilities in the MySQL Workbench and get the following error:
"The command line MySQL Utilities could not be located. To use them, you must download and install the utilities package for your system from www.mysql.com. Click on the Download button to proceed."
However, when I go to the address and download/install, this does not fix the issue.
How do I fix or get around this issue?
I'm running Windows 8.1 64-bit
in error the system is not able to recognize it (MySQL Utilities could not be located) and in default assumes thats Python has been installed and the whole library are developed with Python :
The library is written entirely in Python, meaning that it is not necessary to have any other tools or libraries installed to make it work. It is currently designed to work with Python v2.6 or later and there is no support (yet) for Python v3.1.
so if you don't have Python on your system just install and its should fix the problem.

How to write a cross platform setup script in Ruby

I am new to ruby and just beginning to understand It's potential. So I am trying to use it for my everyday tasks. One of those things would be the setup of a Webservice on a local machine for testing. It set up script should:
check out several projects from subversion repositories
install Hadoop (if it's not already installed), start the Server and execute a few commands in the hbase shell
install the JDK (if not installed)
install MySQL (if not installed) and execute some SQL to create and set up the DB
Install maven (if not installed) and run some maven tasks.
So here's the deal. I want this to be a cross platform installer - it should be able to install the Webservice on Windows, Linux or OsX.
Is it possible to implement this in Ruby and what gems could be useful for that task? Are there better ways to create such an installation routine?
Regards
R.
Have a look at Chef. It provides an automation framework for managing systems. It's written in Ruby and you use a mostly Ruby recipe DSL.
People package Cookbooks for managing groups of installation and configuration recipes, which are normally based around a piece of software.
Hadoop
MySQL
Maven
Java
You will run into issues bridging the gap between Windows and Unix. Although Chef does provide good Windows support these days most Chef/community cookbooks will support Linux primarily as they can rely on the underlying package manager which Windows lacks. Often you may end up finding/using separate Windows cookbooks specifically for the Windows install.
For when you do need to do a Windows install, look at using Chocolatey and it's cookbook which provides a unix like package interface for Windows so you don't need to worry about packaging up the software manually or dealing with random NSIS/MSI installer options.
If you do extend one of the Unix cookbooks to support Windows, be nice and contribute it back to the community.

How to add MySql library into Code::Blocks/MinGW

I need to create a C program that requires a MySQL database. For this, I've seen on the web that I need to use a MySQL connector (which I installed in my PC). I run my code with Code::Blocks/mingw and I don't know how to add the mysql libraries to it.
To connect to a MySQL database I need the mysql.h file (I have the file but I don't know where to place it in my computer). Can you guys help me?
If you're using mingw, then from mingw installer you should find the support for MySQL library. If it doesn't appear there, then you can download the MySQL-devel source tarball and then compile and install it with mingw (you need GCC and other software building tools installed). In this way you'll get support of mysqllib support in mingw like GNU/Linux environment.