!pip install lets_plot==2.1.0
import numpy as np
import pandas as pd
from lets_plot import *
LetsPlot().setup_html()
data = dict(
cond = np.repeat(['A', 'B'], 200),
rating = np.concatenate( (np.random.normal(0, 1, 200), np.random.normal(1, 1.5, 200)))
)
ggplot(data, aes(x = 'rating', fill = 'cond')) + ggsize(500, 250) \
+ geom_density(color = 'dark_green', alpha = 0.7, ) + scale_fill_brewer(type = 'seq') \
+ theme(axis_line_y='blank')
!pip install django==3.2.7
import unittest
from jinjasql import JinjaSql
j = JinjaSql()
userid = ""
sdate = "2016-01-01"
edate = "2017-01-01"
j.prepare_query("select * from user where id = {userid}",
{userid: 143})
j.prepare_query("SELECT username, sum(spend) FROM transactions WHERE start_date > {sdate} AND end_date < {edate}", {sdate: '',edate: ''})
num_of_params = 50000
bind_params = ""
alphabets = ['A'] * num_of_params
source = "SELECT 'x' WHERE 'A' in {{alphabets | inclause}}"
query, bind_params = j.prepare_query(source, {"alphabets": alphabets})
print(len(bind_params), num_of_params)
from django.db import connection
with connection.cursor() as cursor:
cursor.execute(query, bind_params)
for row in cursor.fetchall():
# do something with the results
pass
#print(query, "SELECT 'x' WHERE 'A' in (" + "%s," * (num_of_params - 1) + "%s)")
import sqlite
SELECT * FROM 'data/export.csv'