I am creating a bot that will ask users for api_id, api_hash, phone number and the code that came to this phone for authorization. After you have received everything, create a client to track messages that the user has written to any chats. I have two problems, the first is that it shows the error 400 PHONE_CODE_EMPTY, although the code is there, prints it through print, and the second problem is that it does not see the messages that the user writes, I will wait for any advice
class Data(StatesGroup):
api_id = State()
api_hash = State()
phone_number = State()
code = State()
auth_code = State()
#dp.message_handler(commands='start')
async def start(message):
await bot.send_message(message.chat.id, 'Начнём!')
# ID пользователя
user_id = message.from_user.id
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# вернуть список отдельных значений
conn.row_factory = lambda cursor, row: row[0]
# Позволяет делать SQL запросы
cur = conn.cursor()
# Проверка есть ли ID в БД
ids = cur.execute('SELECT user_id FROM users').fetchall()
print(ids)
for i in ids:
print(5)
if str(user_id) == str(i):
print(1)
await bot.send_message(message.chat.id, 'О, вы уже есть в нашей базе.\n'
'Необходимо авторизоваться!\n'
'Введите код...')
await Data.auth_code.set()
# Конец
await bot.send_message(message.chat.id, 'Теперь напиши magic в любой чат')
else:
print(4)
# Авторизация
await bot.send_message(message.chat.id, 'Чтобы я мог с вами работать, '
'нужно авторизоваться.\n'
'Вам нужно:\n'
'1. Перейти на сайт телеграмма https://my.telegram.org/auth и получить api_id и '
'api_hash\n'
'2. Отправить мне по очереди api_id и api_hash\n'
'3. Авторизоваться у меня по номеру телефона, чтобы '
'я мог сделать magic\n'
'Команды можно вызвать /commands')
# Конец
await bot.send_message(message.chat.id, 'Теперь напиши magic в любой чат')
#dp.message_handler(commands='commands')
async def commands(message):
await message.reply('/api_id - добавление/изменение api_id\n'
'/api_hash - добавление/изменение api_hash\n'
'/phone_number - добавление/изменение номера телефона\n'
'/code - отправить код для авторизации\n')
#dp.message_handler(commands='api_id')
async def api_id(message):
# Получение api_id
await Data.api_id.set()
await bot.send_message(message.chat.id, 'Жду api_id...')
#dp.message_handler(commands='api_hash')
async def api_id(message):
# Получение api_hash
await Data.api_hash.set()
await bot.send_message(message.chat.id, 'Жду api_hash...')
#dp.message_handler(commands='phone_number')
async def api_id(message):
# Получение phone_number
await Data.phone_number.set()
await bot.send_message(message.chat.id, 'Авторизация телефона.\n'
'Отправь мне свой номер телефона в международном формате, '
'т.е. с кодом(пример: +375295892123.\n')
await bot.send_message(message.chat.id, 'Жду номер телефона...')
"""Добавление user_id и api_id в БД
==================================================================================================="""
#dp.message_handler(state=Data.api_id)
async def api_id(message, state: FSMContext):
# ID пользователя
user_id = message.from_user.id
# api_id пользователя
api_id = message.text
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# Позволяет делать SQL запросы
cur = conn.cursor()
# Добавление данных
cur.execute("INSERT INTO users VALUES (?,?,?,?,?,?);",
(int(user_id), str(api_id), str(0), str(0), str(0), str(0)))
conn.commit()
cur.close()
await state.finish()
await bot.send_message(message.chat.id, 'Отлично теперь /api_hash')
"""Добавление api_hash в БД
==================================================================================================="""
#dp.message_handler(state=Data.api_hash)
async def api_hash(message, state: FSMContext):
# ID пользователя
user_id = message.from_user.id
# api_hash пользователя
api_hash = message.text
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# Позволяет делать SQL запросы
cur = conn.cursor()
# Добавление данных
cur.execute("UPDATE users set api_hash = ? WHERE user_id = ?", (str(api_hash), int(user_id)))
conn.commit()
cur.close()
await state.finish()
await bot.send_message(message.chat.id, 'Отлично теперь /phone_number')
"""Добавление phone_number в БД и отправление на номер смс с кодом
==================================================================================================="""
#dp.message_handler(state=Data.phone_number)
async def phone_number(message, state: FSMContext):
api_id = 11956109
api_hash = '2a767c96e93b1c4685aa11017818da52'
# ID пользователя
user_id = message.from_user.id
# api_hash пользователя
phone_number = message.text
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# Позволяет делать SQL запросы
cur = conn.cursor()
# Добавление данных
cur.execute("UPDATE users set phone_number = ? WHERE user_id = ?", (str(phone_number), int(user_id)))
conn.commit()
# Отправление на номер смс с кодом
results_api_id = cur.execute("SELECT api_id FROM users WHERE user_id = ?", (user_id,)).fetchone()
api_id = results_api_id[0]
results_api_hash = cur.execute("SELECT api_hash FROM users WHERE user_id = ?", (user_id,)).fetchone()
api_hash = results_api_hash[0]
print(api_id)
print(api_hash)
app = Client(f'code{user_id}', api_id, api_hash, phone_number, test_mode=True)
await app.connect()
sent_code = await app.send_code(phone_number)
print(sent_code)
cur.execute("UPDATE users set sent_code = ? WHERE user_id = ?", (str(sent_code), int(user_id)))
conn.commit()
await app.disconnect()
cur.close()
await state.finish()
await bot.send_message(message.chat.id, 'Жду кода...')
await Data.code.set()
#dp.message_handler(state=Data.code)
async def code(message, state: FSMContext):
code = message.text
user_id = message.from_user.id
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# Позволяет делать SQL запросы
cur = conn.cursor()
# Добавление данных
cur.execute("UPDATE users set code = ? WHERE user_id = ?", (str(code), int(user_id)))
conn.commit()
cur.close()
await state.finish()
await bot.send_message(message.chat.id, 'Отлично теперь я готов')
#dp.message_handler(commands='on')
async def m(message):
user_id = message.from_user.id
# Подключаемся к БД
conn = sqlite3.connect('data.db')
# Позволяет делать SQL запросы
cur = conn.cursor()
results_api_id = cur.execute("SELECT api_id FROM users WHERE user_id = ?", (user_id,)).fetchone()
api_id = results_api_id[0]
results_api_hash = cur.execute("SELECT api_hash FROM users WHERE user_id = ?", (user_id,)).fetchone()
api_hash = results_api_hash[0]
results_phone_number = cur.execute("SELECT phone_number FROM users WHERE user_id = ?", (user_id,)).fetchone()
phone_number = results_phone_number[0]
results_sent_code = cur.execute("SELECT sent_code FROM users WHERE user_id = ?", (user_id,)).fetchone()
sent_code = results_sent_code[0]
results_code = cur.execute("SELECT code FROM users WHERE user_id = ?", (user_id,)).fetchone()
code = results_code[0]
print(code)
await test(user_id, api_id, api_hash, phone_number, sent_code, message, code)
async def test(user_id, api_id, api_hash, phone_number, sent_code, message, code):
user = Client(f's{user_id}', api_id, api_hash, phone_number)
await user.connect()
signed = await user.sign_in(phone_number, sent_code, code)
print(signed)
if signed:
await message.reply('Подключено')
else:
await message.reply('Ошибка')
#user.add_handler(MessageHandler(msg, filters.me & filters.text))
#user.on_message(filters.me)
def qwe(client, message):
bot.send_message(message.chat.id, message.text)
I am having trouble appending and deleting rows. My table changes a lot and must be rebuilt often so this has been a little tricky. All of my information comes from an SQL database. I am loading the results into a pandas DataFrame and then using it to populate the GridTableBase class. I am now trying to Append and Delete rows, but am having trouble overriding the class. I have been able to somewhat get it to work, but it behaves weird. For some reason, self.table.AppendRows(row) doesn't work and throws an error. The original was self.table.AppendRow(row), but AppendRow isn't a method. So I had to use a different method. I have to change a value in order to get the GridTableMessage to realize there has been a change, which is what I am doing here data.iloc[data.shape[0]-1,0] = str(val)
Ideally, I would add/delete the row from the table itself, but I can't figure out how to do that. I have derived most of my code from here https://github.com/wxWidgets/Phoenix/blob/master/demo/Grid_MegaExample.py but a lot of that will not work properly for me.
As of now, I can append a row, but for some reason, it appends 2 even though only one has been added to the DataFrame and GetNumberRows is returning the correct count. I assume it has something to do with the way I am accessing the table class. Can anyone provide some clarity?
def rowPopup(self, row, evt):
"""(row, evt) -> display a popup menu when a row label is right clicked"""
appendID = wx.Window.NewControlId()#wx.NewId()
deleteID = wx.Window.NewControlId()#wx.NewId()
x = self.GetRowSize(row)/2
if not self.GetSelectedRows():
self.SelectRow(row)
menu = wx.Menu()
xo, yo = evt.GetPosition()
menu.Append(appendID, "Append Row")
menu.Append(deleteID, "Delete Row(s)")
def append(event, self=self, row=row):#event, self=self, row=row
global data
#print("Append")
#self.table.AppendRows(row)
dlg = wx.TextEntryDialog(self,'Enter a new Key ID to insert into the ' + str("'") + data.columns[0] + str("'") + ' column.', 'Insert New Record')
dlg.SetValue("")
if dlg.ShowModal() == wx.ID_OK:
#print('You entered: %s\n' % dlg.GetValue())
val = dlg.GetValue()
#data[~pd.isnull(data).all(1)].fillna('')
#data['tables_id'].apply('(g)'.format)
data.loc[data.iloc[-1].name + 1,:] = ""
data.iloc[data.shape[0]-1,0] = str(val)
self.Reset()
#print(data)
#data = data.append(pd.Series(dtype='object'), ignore_index=True)
#self.data = DataTable(data)
#data[~pd.isnull(data).all(1)].fillna('')
#self.data = DataTable(data)
def delete(event, self=self, row=row):#event, self=self, row=row
global data
rows = self.GetSelectedRows()
data.drop(data.index[rows],inplace=True)
print (data)
self.Reset()
#self.table.DeleteRow(row)
#print(row)
#print(rows)
#EVT_MENU(self, appendID, append)
#EVT_MENU(self, deleteID, delete)
self.Bind(wx.EVT_MENU, append, id=appendID)
self.Bind(wx.EVT_MENU, delete, id=deleteID)
self.PopupMenu(menu, wx.Point(round(x), round(yo)))
menu.Destroy()
class DataTable(gridlib.GridTableBase):
def __init__(self, data):
gridlib.GridTableBase.__init__(self)
self.headerRows = 1
if data is None:
data = pd.DataFrame()
self.data = data
print("Instance")
#Store the row and col length to see if table has changed in size
self._rows = self.GetNumberRows()
self._cols = self.GetNumberCols()
self.odd=gridlib.GridCellAttr()
self.odd.SetBackgroundColour((217,217,217))
self.even=gridlib.GridCellAttr()
self.even.SetBackgroundColour((255,255,255))
def GetAttr(self, row, col, kind):
attr = [self.even, self.odd][row % 2]
attr.IncRef()
return attr
def GetNumberRows(self):
#print("# Rows:",len(self.data))
return len(self.data)# - 1
def GetTypeName(self, row, col):
#print(wx.grid.GRID_VALUE_STRING)
return wx.grid.GRID_VALUE_STRING
def GetNumberCols(self):
#print("# Cols:",len(self.data.columns)+ 1)
return len(self.data.columns) + 1
#return len(self.data.columns) #+ 1
def IsEmptyCell(self, row, col):
return False
def GetValue(self, row, col):
if col == 0:
try:
return self.data.index[row]
except:
print("Row,Col(",row,col,")","OOB")
return ""
else:
try:
return str(self.data.iloc[row, col - 1])
except:
print("Row,Col(",row,col,")","OOB")
return ""
def GetColLabelValue(self, col):
if col == 0:
if self.data.index.name is None:
return 'Index'
else:
return self.data.index.name
return self.data.columns[col - 1]
def ResetView(self, grid):
"""
(wxGrid) -> Reset the grid view. Call this to
update the grid if rows and columns have been added or deleted
"""
print('Old::' , self._rows, self._cols)
print('New::' , self.GetNumberRows(),self.GetNumberCols())
print(data)
grid.BeginBatch()
for current, new, delmsg, addmsg in [
(self._rows, self.GetNumberRows(), gridlib.GRIDTABLE_NOTIFY_ROWS_DELETED, gridlib.GRIDTABLE_NOTIFY_ROWS_APPENDED),
(self._cols, self.GetNumberCols(), gridlib.GRIDTABLE_NOTIFY_COLS_DELETED, gridlib.GRIDTABLE_NOTIFY_COLS_APPENDED),
]:
if new < current:
msg = gridlib.GridTableMessage(self,delmsg,new,current-new)
#grid.ProcessTableMessage(msg)
self.GetView().ProcessTableMessage(msg)
print("OvN:",self._rows,self.GetNumberRows())
return True
if new > current:
msg = gridlib.GridTableMessage(self,addmsg,new-current)
self.GetView().ProcessTableMessage(msg)
grid.ProcessTableMessage(msg)
#self.UpdateValues(grid)
msg = gridlib.GridTableMessage(self, gridlib.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
grid.ProcessTableMessage(msg)
print("OvN:",self._rows,self.GetNumberRows())
grid.EndBatch()
self._rows = self.GetNumberRows()
self._cols = self.GetNumberCols()
# update the column rendering plugins
#self._updateColAttrs(grid)
# XXX
# Okay, this is really stupid, we need to "jiggle" the size
# to get the scrollbars to recalibrate when the underlying
# grid changes.
h,w = grid.GetSize()
grid.SetSize((h+1, w))
grid.SetSize((h, w))
grid.ForceRefresh()
def UpdateValues(self, grid):#self, grid
"""Update all displayed values"""
# This sends an event to the grid table to update all of the values
msg = gridlib.GridTableMessage(self, gridlib.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
grid.table.ProcessTableMessage(msg)
class DataGrid(gridlib.Grid):
def __init__(self, parent, data, lc, tc): # data
gridlib.Grid.__init__(self, parent, - 1) #,colnames,-1 # data
self.lc = lc
self.tc = tc
self.table = DataTable(data)
self.SetTable(self.table, True)
self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClicked)
self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
self.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.onCellChanged) #wx.grid
def Reset(self):
"""reset the view based on the data in the table. Call
this when rows are added or destroyed"""
self.table.ResetView(self)
def OnCellRightClick(self, event):
print ("OnCellRightClick: (%d,%d)\n" % (event.GetRow(), event.GetCol()))
def OnLabelRightClicked(self, evt):
row, col = evt.GetRow(), evt.GetCol()
if row == -1: print("col")#self.colPopup(col, evt)
elif col == -1: self.rowPopup(row, evt)
def rowPopup(self, row, evt):
"""(row, evt) -> display a popup menu when a row label is right clicked"""
appendID = wx.Window.NewControlId()#wx.NewId()
deleteID = wx.Window.NewControlId()#wx.NewId()
x = self.GetRowSize(row)/2
if not self.GetSelectedRows():
self.SelectRow(row)
menu = wx.Menu()
xo, yo = evt.GetPosition()
menu.Append(appendID, "Append Row")
menu.Append(deleteID, "Delete Row(s)")
def append(event, self=self, row=row):#event, self=self, row=row
global data
#print("Append")
#self.table.AppendRows(row)
dlg = wx.TextEntryDialog(self,'Enter a new Key ID to insert into the ' + str("'") + data.columns[0] + str("'") + ' column.', 'Insert New Record')
dlg.SetValue("")
if dlg.ShowModal() == wx.ID_OK:
val = dlg.GetValue()
#data[~pd.isnull(data).all(1)].fillna('')
#data['tables_id'].apply('(g)'.format)
data.loc[data.iloc[-1].name + 1,:] = ""
data.iloc[data.shape[0]-1,0] = str(val)
self.Reset()
#print(data)
#self.data = DataTable(data)
def delete(event, self=self, row=row):#event, self=self, row=row
global data
rows = self.GetSelectedRows()
data.drop(data.index[rows],inplace=True)
print (data)
self.Reset()
self.Bind(wx.EVT_MENU, append, id=appendID)
self.Bind(wx.EVT_MENU, delete, id=deleteID)
self.PopupMenu(menu, wx.Point(round(x), round(yo)))
menu.Destroy()
class MainFrame(wx.Frame):
def __init__(self, parent, data): # (self, parent, data):
wx.Frame.__init__(self, parent, -1, "Varkey Foundation") #, size=(640,480))
#Create a panel
self.p = wx.Panel(self)
self.Maximize(True)
#Create blank dataframe
data = pd.DataFrame() #pd.DataFrame(np.random.randint(0,100,size=(200, 5)),columns=list('EFGHD')
#data.reset_index(drop=True, inplace=True)
self.data = DataTable(data)
self.nb = wx.Notebook(self.p)
self.p.SetBackgroundColour( wx.Colour( 0, 0, 0 ) ) # 38,38,38
self.nb.SetBackgroundColour(wx.Colour(58, 56, 56) )
#self.SetBackgroundColour( wx.Colour( 255, 255, 56 ) )
#create the page windows as children of the notebook
self.page1 = PageOne(self.nb)
self.page2 = PageTwo(self.nb)
self.page3 = PageThree(self.nb)
# add the pages to the notebook with the label to show on the tab
self.nb.AddPage(self.page1, "Data")
self.nb.AddPage(self.page2, "Analyze")
self.nb.AddPage(self.page3, "Change Log")
#CreateFonts
self.b_font = wx.Font(14,wx.ROMAN,wx.NORMAL,wx.BOLD, True)
self.lbl_font = wx.Font(14,wx.ROMAN,wx.NORMAL,wx.NORMAL, True)
self.cb_font = wx.Font(11,wx.SCRIPT,wx.ITALIC,wx.NORMAL, True)
self.h_font = wx.Font(18,wx.DECORATIVE,wx.ITALIC,wx.BOLD, True)
#Create username textcontrol <<<<<<<<<<<< Passed to grid class
self.tc_user =wx.TextCtrl(self.p,value='cmccall95',size = (130,25))
self.tc_password =wx.TextCtrl(self.p,value='Achilles95', style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER,size = (130,25))
self.tc_password.Bind(wx.EVT_TEXT_ENTER,self.onLogin)
self.tc_user.SetFont(self.cb_font)
self.tc_password.SetFont(self.cb_font)
#Create Change log lstCtrl <<<<<<<<<<<< Passed to grid class
self.lc_change = wx.ListCtrl(self.p,-1,style = wx.TE_MULTILINE | wx.LC_REPORT | wx.LC_VRULES)
self.lc_change.InsertColumn(0,"User ID")
self.lc_change.InsertColumn(1,"Status")
self.lc_change.InsertColumn(2,"Description")
self.lc_change.InsertColumn(3,"Date/Time")
#Set column widths
self.lc_change.SetColumnWidth(0, 75)
self.lc_change.SetColumnWidth(1, 75)
self.lc_change.SetColumnWidth(2, 450)
self.lc_change.SetColumnWidth(3, 125)
#Create the grid and continue layout
self.grid = DataGrid(self.page1, data, self.lc_change, self.tc_user)
#More layout code...
def onLoadNewData(self, event): #This is how I'm replacing the data in my table class
global data
self.Freeze()
if self.combo_table.GetValue():
#Connect to db
self.connect_mysql()
#Determine db table
self.getTable()
#Get new data
sql_query = "SELECT * FROM " + tbl
self.cursor.execute(sql_query)
temp = pd.read_sql(sql_query, con=self.db_con)
temp.reset_index(drop=True, inplace=True)
data = temp[~pd.isnull(temp).all(1)].fillna('')
#Create title #if data:
if not data.empty:
self.title.SetLabel(str(self.combo_table.GetValue()))
print(str(self.combo_table.GetValue()))
self.grid.Destroy()
self.grid = DataGrid(self.page1, data, self.lc_change, self.tc_user)
#self.grid.HideCol(0)
self.grid.AutoSizeColumns()
#Insert grid into existing sizer
self.p1_sizer.Insert(1,self.grid,1,wx.RIGHT| wx.LEFT|wx.EXPAND, 20)
self.p1_sizer.Layout()
#RESIZE
else:
print("Error:Dataframe is empty")
self.close_connection()
else:
print('CANT BE BLANK')
self.Thaw()
if __name__ == '__main__':
import sys
app = wx.App()
frame = MainFrame(None, sys.stdout) # (None, sys.stdout)
frame.Show(True)
app.MainLoop()
So, I was working on API with flask. The data is in DB2. I tried to connect with pyodbc as below
#app.route('/api/acrdkl/all', methods=['GET'])
def api_all():
conn = pyodbc.connect("DSN=AS400;UID=....;PWD=....")
cur = conn.cursor()
all_books = cur.execute(""" select trim(dkkdcb), trim(dkkdps), trim(dkcob), trim(dkureg), trim(dkbktg), trim(dkblrg), trim(dkthrg)
from simdta.ACRDKL where dkkdcb=1402 and dkblrg=10 and dkthrg=2020""")
rows = cur.fetchall()
result = []
for dt in rows:
result.append([x for x in dt])
return jsonify(result)
Result are shown as JSON.
But when I tried to use some parameter as below
#app.route('/api/acrdkl/filter', methods=['GET'])
def api_filter():
dkkdcb = request.args.get('DKKDCB', 0)
dkblrg = request.args.get('DKBLRG', 0)
dkthrg = request.args.get('DKTHRG', 0)
query = """selecttrim(dkkdcb),trim(dkkdps),trim(dkcob),trim(dkureg),
trim(dkbktg), trim(dkblrg), trim(dkthrg)
from simdta.ACRDKL WHERE """
conn = pyodbc.connect("DSN=AS400;UID=.....;PWD=.....")
cur = conn.cursor()
rows = cur.execute(query, [int(dkkdcb), int(dkblrg), int(dkthrg)])
rows.fetchall()
print("rows 2 ", rows)
result = []
for dt in rows:
result.append([x for x in dt])
return jsonify(results)
And I go to this http://127.0.0.1:5000/api/acrdkl/filter?DKKDCB=1402&DKBLRG=10&DKTHRG=2020 and it throws error like this
pyodbc.DataError: ('22023', '[22023] [Microsoft][ODBC DB2 Driver]Data
exception - SQLSTATE 22023, SQLCODE -302. SQLSTATE: 22023, SQLCODE:
-302 (-302) (SQLExecDirectW)')
How do I get the desired result? Where is my mistake? Any help would be appreciate. Thanks
I don't see that you are accessing the request data provided by Flask, e.g.:
dkbrlg=request.args.get('dkbrlg',0)
shinyApp code is attached. I'm using data from mysql database and want to display data table based on the query and str and summary of the data. Code is running properly. Do I need to connect to database again and again to get displays of str, summary and table in my shiny app?
library(shiny)
library(DBI)
library(RMySQL)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("city", "country","countrylanguage")),
numericInput("obs", "Number of observations to view:", 10),
submitButton("Update View")
),
mainPanel(
tabsetPanel(tabPanel("Table",tableOutput("view")),
tabPanel("Str",verbatimTextOutput("dump")),
tabPanel("Summary",verbatimTextOutput("stats"))
))
)
)
# Define server logic required to summarize and view the
# selected dataset
server<-function(input, output) {
output$view <- renderTable({
conn <- dbConnect(drv = RMySQL::MySQL(),dbname = "world",host = "localhost",username = "root",password = "xxxx")
on.exit(dbDisconnect(conn), add = TRUE)
head(dbReadTable(conn = conn, name = input$dataset), n = input$obs)
})
output$dump <- renderPrint({
conn <- dbConnect(drv = RMySQL::MySQL(),dbname = "world",host = "localhost",username = "root",password = "xxxx")
on.exit(dbDisconnect(conn), add = TRUE)
str(dbReadTable(conn = conn, name = input$dataset))
})
output$stats <-renderPrint({
conn <- dbConnect(drv = RMySQL::MySQL(),dbname = "world",host = "localhost",username = "root",password = "xxxx")
on.exit(dbDisconnect(conn), add = TRUE)
summary(dbReadTable(conn = conn, name = input$dataset), n = input$obs)
})
# Return the requested dataset
datasetInput <- reactive({
switch(input$dataset
)})
}
shinyApp(ui, server)