<jupyter_start><jupyter_text>DescriptionThis notebook allows to connect to an IM instance and access data.<jupyter_code>%load_ext autoreload
%autoreload 2

import logging

import pandas as pd

import helpers.hdbg as dbg
import helpers.hprint as print_
import helpers.hsystem as si
import os
# dbg.init_logger(verbosity=logging.DEBUG)
dbg.init_logger(verbosity=logging.INFO)
# dbg.test_logger()
_LOG = logging.getLogger(__name__)
#dbname=os.environ["POSTGRES_DB"]
#host=os.environ["POSTGRES_HOST"]
#port=int(os.environ["POSTGRES_PORT"])
#user=os.environ["POSTGRES_USER"]
#password=<PASSWORD>["<PASSWORD>_PASSWORD"]

import helpers.hsql as hsql

import pandas as pd
import pandas.io.sql as sqlio
import psycopg2

conn_as_str = "user= password= dbname=im_postgres_db_local host=im_postgres_local port=5550"
conn = hsql.get_connection_from_string(conn_as_str)

db_names = hsql.get_db_names(conn)
print("db_names=%s" % db_names)

table_names = hsql.get_table_names(conn)
print("table_names=%s" % table_names)

table_name = "tradesymbol"
sql = "SELECT * FROM %s;" % table_name
df = sqlio.read_sql_query(sql, conn)

df<jupyter_output>db_names=['im_postgres_db_local', 'postgres', 'template0', 'template1']
table_names=['exchange', 'tradesymbol', 'symbol', 'kibotdailydata', 'kibotminutedata', 'kibottickbidaskdata', 'kibottickdata', 'ibdailydata', 'ibminutedata', 'ibtickbidaskdata', 'ibtickdata']
{'fraction_non_alphanumeric': 0.1251798561151079, 'fraction_numerical': 0.0057553956834532375, 'mean_word_length': 8.593103448275862, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '146489', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 529, 'n_tokens_neox': 521, 'n_words': 100, 'path': 'im/app/notebooks/Master_IM_DB.ipynb', 'repo_name': 'alphamatic/amp', 'size': '1388'}