vertica

Unique Contrains in Vertica DB

戏子无情 提交于 2019-12-02 03:25:33
Disclaimer: My DB knowledge comes mostly from Mysql so I might misunderstand some things in vertica... I would like to know if there exist a technique of inserting/updating values in vertica while enforcing unique constrains across multiple sessions. Let's assume I have a table: 'id', 'unique_field', 'some_filed' And there is a unique constraint on unique_field. My understanding is that in vertica one first needs to do an insert and then do ANALYZE_CONSTRAINTS to verify if the constraint was violated. In my specific case, I have multiple sessions preforming INSERTS to the same table and they

How do I write a pandas dataframe to Vertica?

淺唱寂寞╮ 提交于 2019-12-01 23:55:28
I have some data set in a pandas data frame that I wish to write to Vertica. I've already created my table using the vertica_python library. What is the best way to write my data frame to Vertica? Often when connecting to Vertica, you can use Postgresql as a stand-in since certain parts of Vertica were originally based on Postgresql. from sqlalchemy import create_engine engine = create_engine('postgresql://user:pass@host:5433/MYDB') df.to_sql('table_name', engine) If this doesn't work you could try out the vertica-sqlalchemy package. Also, depending on the SQL created (and if the ODBC driver

Is there a way to set AUTO_INCREMENT property on existing table column in Vertica?

大憨熊 提交于 2019-12-01 22:34:17
问题 Suppose I have a simple table: CREATE TABLE user( id INT NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, ) Is there a way to alter this table so id will become AUTO_INCREMENT field? I tried the following with no luck: ALTER TABLE (no such syntax) Creating another table with auto increment ID, and copying the data from the original one (didn't work because of the error: Cannot insert into or update IDENTITY/AUTO_INCREMENT column "id") Thanks! 回答1: I would try to just rank the rows, and use

Is there a way to set AUTO_INCREMENT property on existing table column in Vertica?

南楼画角 提交于 2019-12-01 20:03:15
Suppose I have a simple table: CREATE TABLE user( id INT NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, ) Is there a way to alter this table so id will become AUTO_INCREMENT field? I tried the following with no luck: ALTER TABLE (no such syntax) Creating another table with auto increment ID, and copying the data from the original one (didn't work because of the error: Cannot insert into or update IDENTITY/AUTO_INCREMENT column "id") Thanks! I would try to just rank the rows, and use the sequence for future inserts. \set AUTOCOMMIT 'on' CREATE TABLE t1 ( val char(1) ); INSERT INTO t1 VALUES (

unixODBC giving error while running isql [Vertica]

谁都会走 提交于 2019-12-01 15:32:45
Hi I have configured the DSN settings for vertica in Ubuntu 10.10 32 bit version machine. The settings are all fine and I have cross checked them. Here is my odbc.ini file: [VerticaDSN] Description = VerticaDSN ODBC driver Driver = /opt/vertica/lib/libverticaodbc_unixodbc.so Servername = myservername Database = mydbname Port = 5433 UserName = myuname Password = ******* Locale = en_US Similarly I have a odbcinst.ini file. when I run the command: isql -v VerticaDSN I get the following error: [S1000][unixODBC][DSI] The error message NoSQLGetPrivateProfileString could not be found in the en-US

Connecting to Vertica database using SQLAlchemy

本小妞迷上赌 提交于 2019-12-01 12:28:55
I'm trying to connect to a Vertica database using SQLAlchemy. I came across and installed a Vertica dialect at https://github.com/jamescasbon/vertica-sqlalchemy . I've also installed pyodbc. Using a basic tutorial at http://www.pythoncentral.io/sqlalchemy-orm-examples/ , I have the following code snippet :- from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker Base = declarative_base() class

Does Apache Spark load entire data from target database?

☆樱花仙子☆ 提交于 2019-12-01 10:49:05
问题 I want to use Apache Spark and connect to Vertica by JDBC. In Vertica database, I have 100 million records and spark code runs on another server. When I run the query in Spark and monitor network usage, traffic between two servers is very high. It seems Spark loads all data from target server. this is my code: test_df = spark.read.format("jdbc") .option("url" , url).option("dbtable", "my_table") .option("user", "user").option("password" , "pass").load() test_df.createOrReplaceTempView('tb')

aggregate function to concatenate strings in Vertica

匆匆过客 提交于 2019-12-01 03:04:26
问题 have a table in vertica: test like this: ID | name 1 | AA 2 | AB 2 | AC 3 | AD 3 | AE 3 | AF how could I use an aggregate function or how to write a query to get data like this (vertica syntax)? ID | ag 1 | AA 2 | AB, AC 3 | AD, AE, AF 回答1: First, you'll need to compile the udx for agg_concatenate . -- Shell commands cd /opt/vertica/sdk/examples/AggregateFunctions/ g++ -D HAVE_LONG_INT_64 -I /opt/vertica/sdk/include -Wall -shared -Wno-unused-value -fPIC -o Concatenate.so Concatenate.cpp /opt

Vertica: how can you concate values by some order?

一个人想着一个人 提交于 2019-11-29 13:15:11
Suppose you have columns ID | A | B | C 1 | 3 | 1 | 2 2 | 5 | 9 | 1 3 | 1 | 2 | 3 and you want the columns concatenated such that the end result would look like ID | ABC_value_DESC | ABC_value_DESC_colnames 1 | 3,2,1 | A,C,B 2 | 9,5,1 | B,A,C 3 | 3,2,1 | C,B,A where you want to get the col values in Descending order within the new column ABC_value_DESC and then return corresponding name of column in the new column ABC_value_DESC_colnames . How can you do the concatenation of values of multiple columns into a new column in Descending order and return column names by value order (not name order)

Can I integrate a custom PDO wrapper in Laravel

旧巷老猫 提交于 2019-11-29 12:52:00
My fellows at work and I are trying to develop a web application using Laravel with a Vertica database. The only problem is that as soon as you use bindValue or bindParam with this specific database, PHP crashes with a segmentation fault. So I've written a PDO wrapper class that redirects calls to the PHP_ODBC module and that actually works. I was now wondering how to integrate it in Laravel if such a thing is even possible. Okay so after a lot of trial and error, my co-workers and I managed to get things up and running. The most time-consuming part turned out to build the wrapper. Assuming