How to connect to database at MySQL using LUA? - mysql

I try to connect to MySQL using LUA however an error occurs such as:
Module 'luasql.mysql' not found:
no field package.preload['luasql.mysql']
luasql = require "luasql.mysql"
env = assert (luasql.mysql())
con=assert(env:connect("db_name","username","pass","host",port))
How can I connect successfully to MySQL database?

Are you using lua-jdbc ?
Try luarocks install luasql-jdbc
Then install lua-mysql luarocks install luasql-mysql
Run again.
Check the Project: https://github.com/keplerproject/luasql

Related

cannot connect to mysql database ubuntu 20.4 (VPS) "ModuleNotFoundError: No module named 'MySQLdb'"

I am working on the setup of my first unmanaged vps(ubuntu 20.4) and following the document to connect my django site to mysql server "https://www.digitalocean.com/community/tutorials/how-to-create-a-django-app-and-connect-it-to-a-database"
able to setup
python/django/virtualenv
mysql server - tested from mysql workbench on my local machine-Ok
apache2 working ok. able to see the welcome screen with sqlite3.
now moving to mysql. i tried both the way('ENGINE': 'django.db.backends.mysql' and option file '/etc/mysql/my.cnf' to connect to mysql server from django project.
None of the alternatives working. activated virtualenv, installed mysqldb using
a) sudo apt install libmysqlclient-dev default-libmysqlclient-dev
b) pip install wheel
c) pip install mysqlclient
while trying to migrate following error encountered. tried with all the option available on stakoverflow, i found none of them working.
Error:
"
(envFusion) worker#server:~/fusion/fusionerp$ python manage.py makemigrations
Traceback (most recent call last):
File "/home/worker/fusion/envFusion/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 15, in
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
.
.
File "/home/worker/fusion/envFusion/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 17, in
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient? "
with ubuntu 20.04 deafult python version is 3.8 and connecting to mysql with 3.8 is a bit challenge so you need to downgrade python to 3.6 or downgrade to ubuntu 18 if you are starting a fresh.
Found a tutorial to downgrade using alternatives and it worked. But had my other dependencies where i need python >= 3.7. So i had no other choice but refresh my ubuntu 20.04 on vps and configured with postgres. it is working way better than i expected with apache2/restframework/redis.
i suppose that i have a solution to this problem, so when we use a Ubuntu OS, i think that we need to run the next commands to work that package:
sudo apt-get install default-libmysqlclient-dev -y
sudo apt-get install gcc -y
pip3 install mysqlclient
Even if you already tried the first one, it might work. I have a Dockerfile in my GitHub of a Django app, if you want to test it later to see if it works on your machine, it took me a week to find the problem and deploy this app to Oracle Cloud because of this error.
Dockerfile

mysqldump: Couldn't execute 'SHOW PACKAGE STATUS WHERE Db = when rake db:migrate finishes migration

I am running tests on Codebuild using Docker. I am using MySQL 5.7 community server using mysql docker image. In my dockerfile, I am using following apt-get update command to get default-mysql-client.
RUN apt-get install -qq -y build-essential locales nodejs software-properties-common ffmpeg pngquant procps vim default-mysql-client mycli tig httpie > /dev/null
But when migrations run and about to finish it raises error and terminates
mysqldump: Couldn't execute 'SHOW PACKAGE STATUS WHERE Db = 'development'': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PACKAGE STATUS WHERE Db = 'development'' at line 1 (1064)
rake aborted!
failed to execute: `mysqldump`
Please check the output above for any errors and make sure that `mysqldump` is installed in your PATH and has proper permissions.
It was working fine previously and just started since yesterday on Codebuild. Can anybody help regarding this ?
I think Codebuild has migrated to buster debian build and now
default-mysql-client is fetching mariadb-client-10.3 instead of mariadb-client-10.1 and due to that this issue is getting raised.
Moreover, I have tried explicitly replacing default-mysql-client with mariadb-client-10.1 but codebuild fails to find the package and that makes sense since mariadb-client-10.1 is not available for buster.

Apache superset on Mac osx

Hi all I am tried to install the superset on OSX using the Python3. After the installation finished when I tried to add the Database using the mysql:// it said error No Module name MySQLDb. I tried to explore how to solved this, one of tutorial said try to install mysqlclient using pip3 install mysqlclient failed to install with error code mysql.h not found.
Than I following another tutorial used the mysql-connector. After I installed it, finally I can connect to mysql DB and insert table to the system. But when I tried to run the analysis from superset it said no data. Also I tried using SQL Lab and got the error args.
Updated: on my superset currently I am used the mysql+mysql-connector as URI Database connected properly, but when I tested to run a query it said execute() got an unexpected keyword argument 'args'. How to solve this?
Anyone have experience with this problem?
Thanks
Here is what works for me:
brew install python || true
brew install mysql || true
# Required for mysqlclient, see brew info openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
# And now it works
pip3 install mysqlclient
Cheers!
Finally I got it working now.
What I am doing is reinstall the superset, run the brew install mysql-connector-c than run pip install mysqlclient

Laravel 5.4 Migration Error

I am facing a issue that I cannot resolve. I have my app hosted on my server using Ubuntu 16.04, PHP 7.1, MySQL and NGINX. My app works perfect. When I ssh to my server and app root I run the following, php artisan session:table, it runs successfully.
When i run php artisan migrate I get foll0wing error and table is not created in my DB.
[Illuminate\Database\QueryException]
could not find driver (SQL: select * from information_schema.tables where t
able_schema = UNIT3D and table_name = migrations)
[PDOException]
could not find driver
Any ideas? Im trying to use this.https://github.com/thomastkim/laravel-online-users
I would start by determining the exact php modules installed. This can be accomplished by
php -m
look for 'phpX.Y-mysql', if you do not see it then the php module is NOT installed. (Where X.Y correspond to your php version number.
Assuming that you do not see it, you can find the exact package version to install from the repos by typing:
sudo apt-cache search php-mysql
Your results will be similar to:
sudo apt-cache search php-mysql
php-mysql - MySQL module for PHP [default]
php7.0-mysql - MySQL module for PHP
php5.6-mysql - MySQL module for PHP
php-mysqlnd-ms - MySQL replication and load balancing module for PHP
php7.1-mysql - MySQL module for PHP
Install the proper php module for your version. Ex:
sudo apt-get install php7.1-mysql

Django: cannot connect to mysql

I am new to Django and I try to follow the official tutorial. since I want to connect to mysql (installed on my computer, and i checked mysql module does exit in python command line), I set the ENGINE in setting.py to be django.db.backends.mysql . and then I tried to run
python manage.py syncdb
then I got error message like this:
Error loading MySQLdb module
and I cannot run
pip install mysql-python
the error msg is:
Unable to find vcvarsall.bat
so what is this error? and honestly I am not sure about the difference between mysql-python and mysql-connector-python. Since i tried with "pip install mysql-connector-python" and it tells me that requirement already satisfied...
You need to download the windows binary installer for the MySQL drivers for Python. Installing from source will not work since you do not have the development headers in Windows.
You need to install the mysql python connector
sudo apt-get install python-mysqldb