How do I make it appear in the same folder as the file that creates it?

Asked

Viewed 23 times

0

I create this database in python3 but it appears in a previous folder

import sqlite3

nome_banco = 'banco_escola.db'

banco = sqlite3.connect(nome_banco)

1 answer

1

If you want to create a file in a specific directory, just pass an absolute path for the file to be created.

Follow an example:

import sqlite3
nome_banco = '/Users/nomeusuario/database.db'
banco = sqlite3.connect(nome_banco)

This way the file with name database.db will be created in the absolute path desired, in this case will be created in: /Users/nomeusuario/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.