mysql - how to remove white space of select statement in python -


note:the below query not giving output when did print query got know there white space shown below in output.can 1 solve or give solution?

node="some text"  sql=("select * table node='%s.sam'"%node)  print("select * table node='%s.sam'"%node)  cursor.execute(sql)  data=cursor.fetchall()   dat in data:       print(dat) 

output:

select * table node='some text  .sam' 

as mentioned other users can use strip() function remove leading , trailing whitespace. if want remove trailing whitespace can use rspace() function.

also small comment not have question sample code. bad practice use format strings enter parameters sql query allows nasty sql injections if allow user input. driver should have way of entering parameters in safe way.

for example, sqlite3 driver believe can similar following

cursor.execute("select * table node = ?", (node,))


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -