在我的数据库中,有很多以“ ch”开头的名称,但根本没有显示,因此没有选择任何行 但是like运算符可以很好地处理数值...
varnames <-c("Choice 1","Choice 2","Choice 3")
mylist<- setNames(as.list(seq(1,length(varnames))),varnames)
mylist
$`Choice 1`
[1] 1
$`Choice 2`
[1] 2
$`Choice 3`
[1] 3
未选择行
答案 0 :(得分:0)
之所以没有显示,是因为'%ch%'给您的结果是在任何名称为ch的地方
您需要的是'%ch',其余部分保持不变
# Import libraries:
from pandas.core.frame import DataFrame
from sqlalchemy import create_engine
import urllib
# In this example, a pandas dataframe is created as below:
cols = ['key1', 'locationKey', 'locationGroupKey', 'dayType', 'effectiveFromDate', 'effectiveToDate', 'prctAM0', 'prctAM1', 'prctAM2', 'prctPM0', 'prctPM1', 'prctPM2', 'prctEV0', 'prctEV1', 'prctEV02', 'prctAD']
values = [[178,10218,0,'2018-06-06 00:00:00','2018-06-06 00:00:00','2018-06-06 00:00:00',.33,0,0,.33,0,0,.33,0,0,0],
[178,10218,0,'2018-06-06 00:00:00','2018-06-06 00:00:00','2018-06-06 00:00:00',.33,0,0,.33,0,0,.33,0,0,0],
[178,10218,0,'2018-06-06 00:00:00','2018-06-06 00:00:00','2018-06-06 00:00:00',.33,0,0,.33,0,0,.33,0,0,0],]
df = DataFrame(values, columns = cols)
# Create connection:
quoted = urllib.parse.quote_plus('DRIVER={SQL Server};SERVER=myServername;DATABASE=myDBname;UID=fieldReadUser;PWD=myPW')
engine = create_engine('mssql+pyodbc:///?odbc_connect={}'.format(quoted))
# Write into SQL table:
df.to_sql('tbl_Interval, schema='dbo', con=engine, if_exists='append', index = False)