我在将变量插入sqlite3时遇到问题,并且变量被哈希处理。 这是我的代码:
structure(list(rmdup.Name1 = structure(c(9L, 2L, 3L, 2L, 38L), .Label = c("Mcdonald",
"McDonald's", "McDonald's Admiralty", "McDonald's Chatswood Interchange",
"McDonald's Southland F/C", "Mcdonalds Playplace", "McDonalds Sialkot",
"McDonald's Ermelo", "McDonald's Newcastle", "McDonald's Secunda",
"McDonald's Auckland Park", "McDonald's Greenpoint", "McDonald's Observatory",
"McDonald's Woodmead", "McDonald's Ballito", "McDonald's Empangeni",
"McDonald's Richards Bay", "McDonald's Chatterton", "McDonald's Greater Edendale Mall",
"McDonald's PMB CBD", "McDonalds Midlands Mall", "McDonald's Gateway KZN",
"McDonald's Pietermaritzburg", "McDonalds Raisethorpe", "McDonald's Crompton",
"McDonald's Hillcrest", "McDonald's Pavillion", "McDonald's Phoenix Plaza",
"McDonald's Umhlanga", "McDonalds Mount Edgecombe", "McDonald's Kwamashu",
"McDonald's The Ridge Shopping Centre", "McDonald's Amanzimtoti",
"McDonald's Field and West", "McDonald's Field Street", "McDonald's Old Fort Rd",
"Macdonalds", "McDonald's King Dinzulu Rd Berea", "McDonald's SA",
"McDonald's Mthatha"), class = "factor"), rmdup.lat = c(-27.7461555,
31.4668924, 1.4405297, 52.2937467, -29.8542476), rmdup.lng = c(29.9329243,
74.2518024, 103.8014657, -0.6839181, 31.0003004), rmdup.address1 = structure(c(22L,
9L, 1L, 6L, 58L), .Label = c("#01-05, 678A Woodlands Ave 6, Singapore 731678",
"1378 Ang Mo Kio Avenue 1, Singapore 569981", "144 Upper Bukit Timah Rd, Singapore 588177",
"20-21/436 Victoria Ave, Chatswood NSW 2067, Australia", "200 Victoria St, 66, Singapore 188021",
"45 London Rd, Wellingborough NN8 2DP, United Kingdom", "6 Raffles Boulevard, #02-156/#02-157/#02-166 Marine Parade Road, Singapore 039594",
"656 Radford Rd, Basford, Nottingham NG7 7EZ, United Kingdom",
"Al-Hussain Road<U+060C> Lahore, Pakistan", "Bahria Town<U+060C> Phase 7, Near Green Valley<U+060C> Rawalpindi 46000, Pakistan",
"Broughton Shopping Park, Chester Rd, Broughton, Chester CH4 0DP, United Kingdom",
"Dixon Dr, New Auckland QLD 4680, Australia", "Gates Square, Satayana Road, Pakistan",
"Hpcl Fuel Station Shoolgiri Highway,, Bangalore to Chennai Highway, NH 7, Hosur Krishnagiri Road,, Shoolgiri, Shoolgiri - Bengaluru Chennai Highway, Chennai, Tamil Nadu 635109, India",
"Mahmood Ghaznavi Road, Sialkot, Pakistan", "Porras St, Davao City, Davao del Sur, Philippines",
"Princes Fwy, Victoria, Australia", "Tariq Rd, Karachi, Pakistan",
"United Kingdom", "Westfield Southlands, 1239 Nepean Hwy, Cheltenham VIC 3192, Australia",
"1 Kerk St, Ermelo, 2351, South Africa", "Allen St & Memmel Rd, Newcastle, 2940, South Africa",
"Oliver Tambo Dr, Secunda, 2302, South Africa", "1223 Commonwealth Avenue, Allston, MA 02134, United States",
"1651 Broadway, New York, NY 10019, United States", "220 W 42nd St, New York, NY 10036, United States",
"262 Canal St, New York, NY 10013, United States", "31 N Arkansas Ave, Atlantic City, NJ 08401, United States",
"45 Melle St, 2000, South Africa", "Corner Kingsway & University Road, Auckland Park, Johannesburg, 2000, South Africa",
"Fritz Sonnenberg Rd & Granger Bay Boulevard, Green Point, Cape Town, 8051, South Africa",
"Main & Norfolk Rd, Main Rd, Observatory, 7925, South Africa",
"Woodmead Dr & Waterval Road, Woodmead, Sandton, 2191, South Africa",
"1 Main Rd & Premium Promenade Street, Richards Bay, 3900, South Africa",
"Ballito Dr & Moffat Dr, Dolphin Coast, 4418, South Africa",
"Cnr &, Turnbull St, Empangeni, 3880, South Africa", "285 Church St, Pietermaritzburg, 3201, South Africa",
"Chatterton Rd &, Armitage Rd, Pietermaritzburg, 3201, South Africa",
"Greater Mall,, Edendale, Pietermaritzburg, South Africa", "Invesco Ctr, Sanctuary Rd, Chasedene, Pietermaritzburg, 3201, South Africa",
"1 Palm Blvd, Umhlanga Ridge, Umhlanga, 4319, South Africa",
"506 Dr Chota Motala Rd, Pietermaritzburg, 3201, South Africa",
"Burger St & Commercial Road, Pietermaritzburg, 3201, South Africa",
"Josiah Gumede Rd & Crompton St, Pinetown, 3620, South Africa",
"Old Main Rd, Hillcrest, 3650, South Africa", "2 Hillhead Dr, Durban, 4300, South Africa",
"317 Umhlanga Rocks Dr, Umhlanga, 4319, South Africa", "Shop 28, 19 Parthenon Street, Phoenix, 4068, South Africa",
"The Pavilion Centre, Jack Martens road Shop 7B, Checkers Hyper Arcade, Durban, 3611, South Africa",
"Bridge City Mall, Curnick Ndlovu Highway, Durban, KwaMashu, 4360, South Africa",
"481, The Ridge Shopping Centre, Sunset Walk, Shallcross, Durban, 4093, South Africa",
"141 Joe Slovo St, Durban, 4001, South Africa", "15, Galleria Mall, Arbour Rd, Amanzimtoti, 4126, South Africa",
"195 K E Masinga Rd & Umgeni Rd, CBD, Durban, 4001, South Africa",
"3, Oppenheimer Rd, Amanzimtoti, 4126, South Africa", "331 Dr Pixley Kaseme St, Durban, 4001, South Africa",
"162 Tara Rd, Bluff, 4052, South Africa", "337 King Dinuzulu Rd (South ), Berea, 4083, South Africa",
"L17, Bridge City Mall, Curnick Ndlovu Hwy, KwaMashu, 4360, South Africa",
"91400 Overseas Hwy, Tavernier, FL 33070, United States", "35 Nelson Mandela Dr, Mthatha, 5100, South Africa"
), class = "factor")), .Names = c("rmdup.Name1", "rmdup.lat",
"rmdup.lng", "rmdup.address1"), row.names = c(21L, 4L, 10L, 12L,
58L), class = "data.frame")
这是错误:
追踪(最近一次通话): 文件&#34; sqlitetesting.py&#34;,第28行,in maindb.execute(&#34; INSERT INTO密码(密码)VALUES(?)&#34;(encriptado,)) TypeError:&#39; str&#39;对象不可调用
祝你有个美好的一天:D, 路易斯杜阿尔特。
答案 0 :(得分:0)
您可以使用String的format
方法替换
password_var = 'your password'
insert_statement = 'INSERT INTO Password(Password) VALUES ({0})'.format('\'' + password_var + '\'')
然后将execute方法运行为:
maindb.execute(insert_statement)