0

I'm using sqlite to store some values in a database , but the values are from different source so i have to put them in different database so i tried something like:

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

but it didn't work, any solutions or ideas.

The error reported was :

%s within quotes :

 TypeError: unsupported operand type(s) for %: 'sqlite3.Connection' and 'str'

%s without quotes :

 SyntaxError: invalid syntax

1 Answer 1

3

str.__mod__() is a method on str:

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

Or because fullpath is already a string:

db = sqlite3.connect(fullpath)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.