python - How to create or open a database with a value stored in a variable -


i'm using sqlite store values in database , values different source have put them in different database tried like:

 source_name = "hello"  ext = ".db"  path = "d:/"  fullpath = path + source_name + ext  db = sqlite3.connect("%s") % (fullpath) 

but didn't work, solutions or ideas.

the error reported :

%s within quotes :

 typeerror: unsupported operand type(s) %: 'sqlite3.connection' , 'str' 

%s without quotes :

 syntaxerror: invalid syntax 

str.__mod__() method on str:

db = sqlite3.connect("%s" % fullpath) 

or because fullpath string:

db = sqlite3.connect(fullpath) 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -