with the connector python, the sql query work fine. However, when i use an instruction (put file file:///localfile), i have an error:
TypeError: init() missing 1 required positional argument: 'backend'
With snowSql on the same Server, it's work.
the code used:
import snowflake.connector
ctx = snowflake.connector.connect(
user='lincavo',
account='*****',
password='*******',
database='DEV_POC_VELOS_DB',
schema='DATALAB',
role='dev_data_analyst'
)
cur = ctx.cursor()
FILE_NAME = "/home/lincoln/DEV/snowflake/100003097-SC.json"
sql="PUT file:///home/lincoln/DEV/snowflake/100003097-SC.json #local_velos_json auto_compress=false"
cur.execute(sql)
snowflake-connector-python 2.6.2
can you help me please ?
thanks
Related
I'm using doctrine in a project (not symfony). In this project I also use phpstan, i installed both phpstan/phpstan-doctrine and phpstan/extension-installer.
My phpstan.neon is like this:
parameters:
level: 8
paths:
- src/
doctrine:
objectManagerLoader: tests/object-manager.php
Inside tests/object-manager.php it return the result of a call to a function that return the entity manager.
Here is the code that create the entity manager
$database_url = $_ENV['DATABASE_URL'];
$isDevMode = $this->isDevMode();
$proxyDir = null;
$cache = null;
$useSimpleAnnotationReader = false;
$config = Setup::createAnnotationMetadataConfiguration(
[$this->getProjectDirectory() . '/src'],
$isDevMode,
$proxyDir,
$cache,
$useSimpleAnnotationReader
);
// database configuration parameters
$conn = [
'url' => $database_url,
];
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);
When i run vendor/bin/phpstan analyze i get this error:
Internal error: An exception occurred in the driver: SQLSTATE[08006] [7] could not translate host name "postgres_db" to address: nodename nor servname provided, or not known
This appear because i'm using docker and my database url is postgres://user:password#postgres_db/database postgres_db is the name of my database container so the hostname is known inside the docker container.
When i run phpstan inside the container i do not have the error.
So is there a way to run phpstan outside docker ? Because i'm pretty sure that when i'll push my code the github workflow will fail because of this
Do phpstan need to try to reach the database ?
I opened an issue on the github of phpstan-doctrine and i had an answer by #jlherren that explained :
The problem is that Doctrine needs to know what version of the DB server it is working with in order to instantiate the correct AbstractPlatform implementation, of which there are several available for the same DB vendor (e.g. PostgreSQL94Platform or PostgreSQL100Platform for postgres, and similarly for other DB drivers). To auto-detect this information, it will simply connect to the DB and query the version.
I just changed my database url from:
DATABASE_URL=postgres://user:password#database_ip/database
To:
DATABASE_URL=postgres://user:password#database_ip/database?serverVersion=14.2
I'm running my script in Spyder/conda... was forced to update one thing, which lead to another. Finally, I am stuck trying to fix this error, which is pretty important, because I cannot get my data or fill tables with the result of my analysis without connecting to snowflake.
To verify my connection I am now simply trying to run their boilerplate connection script:
#!/usr/bin/env python
import snowflake.connector
# Gets the version
ctx = snowflake.connector.connect(
user='email',
password='pw',
account='acct'
)
cs = ctx.cursor()
try:
cs.execute("SELECT current_version()")
one_row = cs.fetchone()
print(one_row[0])
finally:
cs.close()
ctx.close()
I keep getting the "OperationalError: 250003: Failed to execute request: 'SSLSocket' object has no attribute 'connection'" error, and am not sure what to do after reinstalling sqlalchemy, pyarrow, pandas, snowflake-connector-python
Any help/suggestions welcome! I'm out of ideas today.
I am trying to run the following Groovy scripts which intends to alter file permissions to 777 on a linux server -
#GrabConfig(systemClassLoader = true)
#Grab(group="com.jcraft", module="jsch", version="0.1.46")
import com.jcraft.jsch.*;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.ChannelSession;
import java.io.InputStream;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Vector;
java.util.Properties config = new java.util.Properties()
config.put "StrictHostKeyChecking", "no"
JSch ssh = new JSch();
Session session = null;
Session sess = ssh.getSession ("USERNAME", "HOST", 22);
sess.with {
setConfig config
setPassword ("PASSWORD");
connect()
Channel chan = openChannel ("sftp");
chan.connect()
ChannelSftp sftp = (ChannelSftp) chan;
"chmod 777".execute(null, new File("WORKING DIRECTORY\Test_ftpuser_place.txt"))
chan.disconnect()
disconnect()
}
Furthermore, I tried with the following command instead of Chmod, but still it didn't work.
builder = new AntBuilder()
builder.chmod(dir:"WORKING DIRECTORY", perm:'+rwxrwxrwx', includes:'Test_ftpuser.txt')
And im getting this error on running the former part of the script -
java.io.IOException: Cannot run program "chmod": CreateProcess error=2, The system cannot find the file specified
at java_lang_Runtime$exec$0.call(Unknown Source)
at ConsoleScript45$_run_closure1.doCall(ConsoleScript45:45)
at ConsoleScript45.run(ConsoleScript45:18)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
... 3 more
Could someone please help me out with this.
Thank you!
See this line:
"chmod 777".execute(null, new File("WORKING DIRECTORY\Test_ftpuser_place.txt"))
The second parameter in the "execute" method represents the current working directory (see the docs here). You're using it to represent the file you're looking to change, which I don't think is what it was intended for.
Try creating the file first, and then changing its permissions. You can also use methods on the File object to set these, without having to use "process".execute():
def myFile = new File("path/to/file")
myFile.write("Hello World")
myFile.setReadable(true, false)
myFile.setWritable(true, false)
myFile.setExecutable(true, false)
I am writing a script to log all the return code of any errors occurring when executing a sqoop operation?
for eg we have different sqoop tools like:
sqoop eval, sqoop import, sqoop export etc.
When execution one of the tools we would get a return code. If the execution was success ful we get return code=0. If not successful we get some other return code based the type of the error.
Is there any way we can log these errors and return code?
I have tried using Java code:
Use Sqoop.runTool api.
int ret = Sqoop.runTool(yourcommand.toArray(new String[yourcommand.size()]));
Please refer to this for more info: Link
Hope this helps.
I'm trying to run a Groovy script to connect to Microsoft SQL Server within Jenkins and insert new data . I want to use the SQL Server driver and I placed the driver in Jenkins\war\WEB-INF\lib. I get an error when I Tried to run the following code in the build step - Execute Groovy Script:
import groovy.sql.Sql
import com.microsoft.sqlserver.jdbc.SQLServerDriver
class Connection {
def sqlConnection
def route = "xxxx"
def user = "xxxx"
def password = "xxxxx"
def driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
Connection(db){
this.route+=db.toString()
this.sqlConnection = Sql.newInstance( route, user, password, driver )
}
static main(args) {
Connection con = new Connection("nameDataBase")
}
}
The error is:
1 error org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
E:\Jenkins\workspace\pruebaDB\hudson1035758401251924782.groovy: 2:
unable to resolve class com.microsoft.sqlserver.jdbc.SQLServerDriver # line 2, column 1.
import com.microsoft.sqlserver.jdbc.SQLServerDriver`
The most evident case of such exception is that necessary class not yet in classpath during script execution.
During a which build step script is executed?
If my assumptions are right and you can't shift script execution time to the other build step (when all necessary classes/libs will be in the cp) try to use class loader.
Here is a few links which should help you with this:
class lodding fun
class loading in groovy