i have student db in my localhost but still it showing this - rmysql

install.packages("RMySQL")
library(RMySQL)
library(dbConnect)
install.packages("dbConnect", type = "source")
library(dbConnect)
mysqlconnection = dbConnect(MySQL(), user = 'root', password = '', dbname = 'student', host = 'localhost')
Error in .local(drv, ...) : Failed to connect to database: Error: Unknown database 'student':

mysqlconnection = dbConnect(MySQL(), user = 'root', password = '', dbname = 'student',
port = 3308)
dbListTables(mysqlconnection)

Related

How I can pass this SQL Query to TypeORM?

I want to sort the closest users by a user
SELECT usuario1.nickname, usuario1.name
FROM public."user" as usuario1, public."user" as usuario2
WHERE usuario1.nickname != 'Lucas' and usuario2.nickname = 'Lucas'
ORDER BY ST_Distance(usuario1.geometry, usuario2.geometry) ASC;
You can execute raw queries in Typeorm with the created connection
import {createConnection, Connection} from "typeorm";
const connection = await createConnection({
type: "mysql",
host: "localhost",
port: 3306,
username: "test",
password: "test",
database: "test"
});
async function getUsers() {
await connection.connect();
const users = await connection.query(`
SELECT usuario1.nickname, usuario1.name
FROM public."user" as usuario1, public."user" as usuario2
WHERE usuario1.nickname != 'Lucas' and usuario2.nickname = 'Lucas'
ORDER BY ST_Distance(usuario1.geometry, usuario2.geometry) ASC
`);
}

how to input nodejs variable into oracle sql query

I am trying to pass a nodejs variable to a sql query
Below is my code:
var b= 101;
connection = await oracledb.getConnection( {
user : dbConfig.user,
password : dbConfig.password,
connectString : dbConfig.connectString
});
sql = 'SELECT * FROM mytab where id= b';
binds = {};
options = {
outFormat: oracledb.OBJECT // query result format
};
result = await connection.execute(sql, binds, options);
try something along these lines:
sql = 'SELECT * FROM mytab where id= $1::int';
options = {
outFormat: oracledb.OBJECT // query result format
};
result = await connection.execute(sql, [ b ], options);

Error: Server did not accept user credentials

Pop3Client pop3Client;
if (Session["Pop3Client"] == null)
{
pop3Client = new Pop3Client();
pop3Client.Connect("pop.gmail.com", 995, true);
pop3Client.Authenticate("myusername","mypwd",AuthenticationMethod.UsernameAndPassword);
Session["Pop3Client"] = pop3Client;
}
Error : Server did not accept user credentials

Lua Invalid HTTP request - Stripe API

I'm trying to write a module to communicate with Stripe's payment API. Already, i've come across trouble. I keep getting a response: ""Your client sent an invalid HTTP request." I've tried every possible thing I could think of..even b64..however, nothing seems to work. Any ideas?
Here is my code:
description = "test"
email = "test#email.com"
api_key = "pk_test_4PRPYs3eM4HQx0ZMBOubGjoy"-- Don't worry, this is a public test key ;)
cardNumber = "4242 4242 4242 4242"
fullName = "Test Name"
expMonth = "07"
expYear = "2016"
cvc = "432"
------------------------------------------------------------
firstCard = {["number"] = cardNumber, ["exp_month"] = expMonth, ["exp_year"] = expYear, ["cvc"] = cvc, ["name"] = fullName}
StripeNewRegister = function ()
local json = require "json"
print ("test")
newCustomer = {["email"] = email, ["description"] = description} --["card"] = firstCard}
print(newCustomer)
local function networkListener( event )
if ( event.isError ) then
print( "Network error!" )
else
print( "RESPONSE: "..event.response )
local data1 = event.response
local resp1 = json.decode(data1)
print(resp1)
local error = resp1.error
if error ~= nil then
for i = 1, #resp1.error do
print(resp1.error[i].type)
print(resp1.error[i].message)
end
end
if error == nil then
-- Print Functions
end
end
end
local key = {["Bearer"] = api_key}
local headers = {
["Authorization Bearer"] = api_key
}
local params = {}
params.headers = headers
params.body = json.encode( newCustomer )
print( "params.body: "..params.body )
network.request( "https://api.stripe.com/v1/customers", "POST", networkListener, params)
end
StripeNewRegister()

DB drivers not specified

I have perl script which on running gives me this error.What could be the error ? because i just changed the host and DB connection setings. Earlier the script worked fine.
I get below error
"dbi:Oracle:host=localhost;sid=nms", 'user', 'password', no database driver specified and DBI_DSN env var not set at ./test.pl line 9..
And here's the code:
sub connect{
my $self = shift;
$logger->debug("Connecting to: " . $self->{config}->{connection}->{host});
$self->{db} = DBI->connect("$self->{config}->{connection}->{host}",
"$self->{config}->{login}->{user}",
"$self->{config}->{login}->{password}")
or ($logger->fatal("Connection Failed : " . $DBI::errstr . " : " . $self->{config}->{login}->{user} . ":" . $self->{config}->{login}->{password} )
and return 0);
return 1; }–
You're missing "dbi:Oracle:", and when connecting to Oracle you don't use host but refer to name from Tnsnames.ora, ie. ORA11 or using complete string instead:
$CFG->{TNS_NAME} = "(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORA11)
)
)";
# ..
$CFG->{TNS_NAME} = "ORA11";
my $DB = DBI->connect(
"dbi:Oracle:",
"$CFG->{USER}/$CFG->{PASSWORD}#". $CFG->{TNS_NAME},
"",
{
ChopBlanks => 1,
AutoCommit => 0,
RaiseError => 1,
},
);
Are you sure your dns var is correct ?
it should be formatted like that : "dbi:<driver>:<database>:<host>:<port>";
use DBI;
$database = 'your_db_name';
$host = 'test.com';
$port = '1521';
$user = 'your_user';
$password = 'your_password';
$dsn = 'dbi:Oracle:'.$database.':'.$host.':'.$port;
$db = DBI->connect($dsn, $user, $password, { 'RaiseError' => 1, 'PrintError' => 0, 'AutoCommit' => 0 })
or die "Unable to connect: $DBI::errstr";
You can also try to set your ORACLE_HOME and ORACLE_OWNER env variable before your DBI->connect():
$ENV{'ORACLE_HOME'} = '...' # path to your oracle lib
$ENV{'ORACLE_OWNER'} = 'oracle'; # Owner