Bygga upp db från pandas
x = pd_data.loc[:,'Livsmedelsnamn':'Livsmedelsnummer']
tuple_list = [tuple(item) for item in x.values]
for food_item in tuple_list:
cs.execute("INSERT INTO LIVS (NAMN, NUMMER) VALUES (%s,%s);",(food_item[0],str(food_item[1])))
Läsa
allrows = cs.execute('select * from livs;').fetchall()
Skapa nya tabeller
sql = 'CREATE TABLE simons(omdoeme INT, nummer CHAR(4), PRIMARY KEY (nummer));'
new_table = cs.execute(sql)
cs.execute("INSERT INTO LIVS (NAMN, NUMMER) VALUES ('Ett livsmedel','Ett nummer');")
Andra datatyper: float(16)
Ansluta till db
import snowflake.connector
# Connecting to Snowflake using the default authenticator
ctx = snowflake.connector.connect(user=sf_user_admin,password=sf_password_admin,account=sf_account,database='glad1',schema='public')
cs=ctx.cursor()
ctx.close()
Det man ville slippa:
%%bash
CFFI_VERSION=$(pip list 2>/dev/null | grep cffi )
echo $CFFI_VERSION
if [[ "$CFFI_VERSION" == "cffi (1.10.0)" ]]
then
pip uninstall --yes cffi
fi
yum_log=$(sudo yum install -y libffi-devel openssl-devel)
pip_log=$(pip install --upgrade snowflake-connector-python)
if [[ "$CFFI_VERSION" == "cffi (1.10.0)" ]]
then
echo "configuration has changed; restart notebook"
fi
Comments
You can follow this conversation by subscribing to the comment feed for this post.