Airflow initdb command fails after linking with postgresql - database

I am trying to connect Airflow with a Postgresql DB.
When in airflow.cfg I change the sql_alchemy_conn = spostgresql+psycopg2://127.0.0.1:5432/airflow, where airflow is the name of my DB which is installed on the same machine.
After updating the config file, I run airflow initdb and get the following error which I cannot understand:
File "/some_path/env/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 232, in load
"Can't load plugin: %s:%s" % (self.group, name)
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:spostgresql.psycopg2
I found this on the web, which seems to "solve" this problem, but the solution was not clear to me at all.
Can someone tell me what the problem is and how to solve it?

Looks to me like you have a typo in your sqlalchemy connection string (s at the beginning of postgres). Try changing:
spostgresql+psycopg2://127.0.0.1:5432/airflow
to
postgresql+psycopg2://127.0.0.1:5432/airflow

Related

Airflow 2.0 SQL Server connector

I want to use the airflow 2.01 docker-compose file from apaches github.
here is the link docker-compose.yaml and here is the link to the dockerfiledockerfile
I want to use a Dag which should grab data out of my SQL Server database. Actually I get the following error:
no module named pymssql
After I manually installed it, I get an error like no module named pyodbc.
When I want to install this manually I get an gcc error, that it is not possible to install.
Does anyone have any clue about this?
Is there any docker-compose file which is able to handle SQL Server connection for Airflow 2?
Thanks in advance

Connect MS SQL with PHP 5.6 on Centos7

Im trying to connect a project to an MS SQL but I can't. I read a lot but no one answer helps me.
Now I´m trying with ADOdb with mssql driver but the connection answer is:
Missing extension for mssql
So I suppose I have to install it but I can't find how can do it for PHP 5.6 on Centos. Anyone?
Or maybe other way to reach the DB?
I already tried yum install php56-php-mssql, php56w-mssql but all of them are miss. And yum install php-mssql answer that package
is already installed
UPDATE
1) tsql test works
2) php-mssql connection in php also works WHEN RUN FROM THE SHELL
3) running PHP through apache does NOT work.
I found the mssql.so and added the path to my php.ini file, then restarted apache but when I load a page with phpinfo(), mssql.so doesn't show.
What is missing?
PROBLEM SOLVED
1) Download PHP5.6 source files.
2) go to php/ext/mssql
3) do phpize but with php used by Plesk located on /opt/plesk/php/5.6/bin/phpize
4) configure, make
5) copy generated *.so to extensions folder on /opt/plesk/php/5.6/lib64/php/modules
6) create /opt/plesk/php/5.6/etc/php.d/mssql.ini file with tho following text:
; Enable mssql extension module
extension=mssql.so
7) restart apache

Configuring a Postgresql connection with Play 2 and Slick-Play

I'm learning how to build an application using Scala and the Play 2 Framemork. I`ve created a new project using the activator tool, based on "play-scala-intro" current template.
The template have a sample app using the Play-Slick 1.0 for managing dependencies and is configured with a H2 DB, that worked without problems.
When I tried to change to a Postgres DB, I'm running in trouble. I get an error 500, telling me:
"Cannot connect to database [default]".
In the stack trace, the exception is:
"Configured Slick driver org.postgresql.Driver is not an instance of
requested profile slick.profile.BasicProfile"
So... What I already did:
I added to my build.sbt file the dependency:
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41"
In my configuration file (application.conf), the DB connection is configured as:
slick.dbs.default.driver=org.postgresql.Driver
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/hello_play"
slick.dbs.default.db.user="postgres" slick.dbs.default.db.password=""
PS: I've tried with slick.dbs.default.driver="org.postgresql.Driver" too...
PS2: My db password is empty. I'm connecting with PgAdmin without problems
slick.dbs.default.driver must be a slick driver, not a JDBC driver. Your db config should look something like this:
slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/hello_play"
slick.dbs.default.db.user="postgres"
slick.dbs.default.db.password=""

ClassNotFoundException with Netbeans and H2 Database

So I followed the tutorial on the H2 Documentation page and used the "Connecting to a Database using JDBC" method of connecting to the database. I First added the h2-*.jar file to the Lib Folder (through Netbeans) and used the following to make the connection to my database I previously created.
Class.forName("org.h2.Driver");
connection = DriverManager.getConnection("jdbc:h2:~/" + DatabaseName);
This turned out to work in the IDE environment, however when I attempted to run the application directly from the jar executable I get the following error:
java.lang.ClassNotFoundException: org.h2.Driver ...
this error occurs at the Class.forName() class loader. So I did a little looking around and found that this was a prominent problem. One solution people use was to extract the class Loader from the current Thread as so:
Thread t = Thread.currentThread();
ClassLoader cl = t.getContextClassLoader();
cl.getClass().getClassLoader();
Class toRun = cl.loadClass("org.h2.Driver");
Unfortunately this seems to still result in the same error, so i'm wondering what i'm doing wrong. Should I be doing something to make sure the Driver is in the class path? I have no I idea how if that's the case.
Thanks!
You need to add the h2-*.jar file to the classpath when running the application, for example using
java -cp h2*.jar -jar yourApp.jar

Connect to postgresql database via MATLAB error

I am trying to connect my Postgres database in MATLAB and it is throwing me an error stating
"'JDBC Driver Error: org.postgresql.Driver. Driver Not Found/Loaded.'"
Here's my connection method that i have used.
conn = database('postgres','username','password','org.postgresql.Driver', 'jdbc:postgresql://localhost:5432/postgres=postgres');
after that it throws me the error.
I have looked at forums and they told me to add the postgres jar files to the MATLAB directory toolkit textfile, such as below.
C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc3.jar
C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc4.jar
I don't know where else I am going wrong. Please advise.
Thank you.
You should add jar file with JDBC driver to your dynamic java class path before connecting to database. I believe you can add only one file depending on your requirements. Check the versions difference here.
To avoid warning if a jar file already in the path add some check:
%# add class path (if not in the class path)
p = 'C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc3.jar';
if ~ismember(p,javaclasspath)
javaaddpath(p)
end

Resources