I try use tarantool as application server and want connect from tarantool to mysql.
In lua i write a function:
local function mysql_data(query, limit)
local conn = mysql.connect({host = mysql_host, user = mysql_user, password = mysql_password, db = mysql_database})
local tuples = conn:execute(query, limit)
return tuples
end
but in log i see:
2016-03-29 17:57:37.358 [8553] main/101/grepmaillog_app.lua F> /home/lua/./grepmaillog_app.lua:12: module 'mysql' not found:
no field package.preload['mysql']
no file './mysql.lua'
no file './mysql/init.lua'
no file '/root/.luarocks/share/lua/5.1/mysql.lua'
no file '/root/.luarocks/share/lua/5.1/mysql/init.lua'
no file '/root/.luarocks/share/lua/mysql.lua'
no file '/root/.luarocks/share/lua/mysql/init.lua'
no file '/usr/local/share/tarantool/mysql.lua'
no file '/usr/local/share/tarantool/mysql/init.lua'
no file '/usr/share/tarantool/mysql.lua'
no f
How i can install package mysql for tarantool ?
Please install tarantool-mysql package from http://tarantool.org/download.html
Related
I'm trying to connect to a MySQL database. In the Documentation its recommended to use DBInterface.connect with a Type MySQL.Connection Object. The Database im trying to connect to gets listed with the mysql> SHOW DATABASES; command so there should be no problem on the MySQL side of things.
For now I implemented:
module Database
using MySQL
using DBInterface
const HOST = "localhost"
const USER = "root"
const PASS = "#####"
const DB = "databank"
const CONN = DBInterface.connect(MySQL.Connection, HOST, USER, PASS, db=DB)
export CONN
disconnect() = DBInterface.close!(CONN)
# gets called for cleanup
atexit(disconnect)
end
But when I call CONN from the REPL I get:
julia> using Database
julia> CONN
MySQL.Connection(disconnected)
julia>
I already checked this Question for answeres, but my implementation should be the same.
Later down the line I was hoping to use DBInterface.execute(CONN, sql) but I get the error ERROR: mysql connection has been closed or disconnected
I tried downloading the sql (sql.lib and sqld.lib) drivers to the MSCV and MINGW files ; it did not work. I then tried through QODBC3 driver and its still not connecting to the database.
I get the following error message.
13:20:05: Starting
C:\build-test1-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\test1.exe ...
13:21:17:
C:\build-test1-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\test1.exe exited
with code 0
//QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3","QMYSQL");
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3","hello");
// db.setDatabaseName("Driver={MySQL ODBC 8.0 ANSI Driver};DATABASE=hello;");
db.setHostName("127.0.0.1");
db.setDatabaseName("hello");
db.setUserName("localhost");
db.setPassword("");
if (db.open()){
QMessageBox::information(this,"Connection","Database connected succesfully");
}
else {
QMessageBox::information(this,"Connection","Database not connected succesfully");
This is my code, also I did add sql in the pro files.
I am trying to connect to the mysql database at localhost with D but when i want to compile my code i am getting the following error from the terminal:
module mysql is in file 'mysql.d'
which cannot be readimport path[0] = /Library/D/dmd/src/phobos
import path[1] = /Library/D/dmd/src/druntime/import
#!/usr/bin/env dub
import mysql;
void main (){
//Connect
con = new Connection("host=localhost; port =3306; user=root; pwd=password; db=awesomeschema");
scope(exit) con.close();
if (con.closed()){
writeln("connected");
} else {
writeln("conn closed");
}
}
Your code example has no dependencies listed.
No Mysql client library has been requested. Hence it fails to compile.
i'm having a little problem. I'm using Debian and I got asterisk 1.8 and I want to use CDR along with mysql.
In Asterisk 1.8 you apparently gotta use cdr-adaptive module instead of the regular. That is just what I did. Now I have 1 error when I "module reload cdr_adaptive_odbc.so" and I can't solve it :
WARNING[23172]: cdr_adaptive_odbc.c:123 load_config: No such connection 'MySQL-asterisk' in the 'adaptive-connection' section of cdr_adaptive_odbc.conf. Check res_odbc.conf.
Now here are all the files related, I can't understand what is wrong :
/etc/odbc.ini :
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/libmyodbc3.so
FileUsage = 1
[Text]
Description = ODBC for Text Files
Driver = /usr/lib/libodbctxt.so
Setup = /usr/lib/libodbctxtS.so
FileUsage = 1
CPTimeout =
CPReuse =
[PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[DB2]
Description = DB2 Driver
Driver = /opt/IBM/db2/V8.1/lib64/libdb2.so
FileUsage = 1
DontDLClose = 1
DMEnvAttr = SQL_ATTR_UNIXODBC_ENVATTR={DB2INSTANCE=db2inst1}
[MySQL-asterisk]
Description = MySQL asterisk database
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = root
Password = XXXXX
Database = ics
Option = 3
/etc/asterisk/cdr_adaptive_odbc.conf :
[adaptive-connection]
connection = MySQL-asterisk
table = cdr
alias start => calldate
/etc/asterisk/res_odbc.conf :
[Asterisk]
enabled => yes
dsn => MySQL-asterisk
username => root
password => XXX
;pooling => no
;limit => 0
pre-connect => yes
This is what I get when i check the cdd status :
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: No
* Registered Backends
-------------------
Adaptive ODBC
cdr-custom
ODBC
csv
radius
res_config_sqlite
And this is what I get when i check de odcb
ODBC DSN Settings
-----------------
Name: Asterisk
DSN: MySQL-asterisk
I can't figure out what's wrong. Anyone has an idea ?
I assume you've fixed this now. I ran into a similar issue and the problem stemmed from the documentation. It refers to connection= in cdr_adaptive_odbc.conf being the DSN name. It's the name you want and not the DSN. So in your case:
connection = Asterisk
then at the command line do a
CLI> module reload cdr_adaptive_odbc.so
and you should see a screenfull as Asterisk finds the tables and does any mappings you have specified.
I have grails 2.0 which comes with H2 database and dbconsole.
I want to take the database backup from dbconsole:
databse url : "jdbc:mysql://localhost/opal"
Username : root
password: (none)
in the tools section of dbconsole there is a option to backup the database.
it will ask 3 things
Target file name: ~/backup.zip(by default)
Source directory:
Source database name: opal (name of my database)
when i press run , it gives error,
No database files have been found in directory E:/Workspace/opal for the database opal
can anybody suggest how to take the database backup.
I've never gotten that to work. If you just want a snapshot of data for development (load on startup) I found that using DBUnit to export/import the data worked great for me. I wrote a script to export it that I call from the console:
class DataExport {
def ctx = SCH.servletContext.getAttribute(GA.APPLICATION_CONTEXT)
def exportData() {
println "-->export"
def ds = ctx.dataSourceUnproxied
println ds.dump()
Connection jdbcConnection = ctx.dataSourceUnproxied.getConnection()
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
println connection.dump()
ITableFilter filter = new DatabaseSequenceFilter(connection);
IDataSet dataset = new FilteredDataSet(filter, connection.createDataSet());
FlatXmlDataSet.write(dataset, new File("full.xml").newWriter());
connection.close()
}
}
And then in bootstrap you can load it back in
Connection jdbcConnection
FlatXmlDataSet dataSet = new FlatXmlDataSetBuilder().build(new ClassPathResource('resources/data/full.xml').inputStream)
jdbcConnection = ctx.dataSource.getConnection()
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
try {
DatabaseOperation.INSERT.execute(connection, dataSet)
} catch(e) {
e.printStackTrace()
throw(e)
} finally {
jdbcConnection.close()
}
log.info 'data loaded'
I think this site would be quite helpful. Or, on taking dump of the database and to restore the database try snippet below:
mysqldump -u root -p my_database Table1 Table2 > /home/user/tablesDump.sql;
and to restore the table(s) back:
mysql -u root -p my_database_2
mysql> source /home/user/tablesDump.sql;
Both tables were created in my_database_2.