Helper function for constructing URIs for `sqlite3.connect()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Feature or enhancement
Proposal:
When working with SQLite3 URIs, one very subtle thing about them is if you are on Windows and the database path starts with a drive letter, you need to make sure there's a leading /. You must also use POSIX file path separators.
A non-optimized solution is:
db_path = path.resolve(strict=True).as_posix()
if not db_path.startswith("/"):
# Starts with a Windows drive letter, so add leading slash.
db_path = "/" + db_path
This seems subtle enough to potentially warrant a function to take a pathlib.Path object and construct the resulting file: URI appropriately. I'm sure something nicer that doesn't force the absolute path could be used to save on any extra stat calls (if people are even that concerned for a single call that opens a database).
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo l’entry point sqlite3.connect() e il comportamento di pathlib.Path descritto nella proposta, quindi esamina i requisiti URI di SQLite. Il lavoro è completato quando è stato concordato e implementato un helper che costruisca l’URI file: appropriata a partire da un Path, incluse le lettere delle unità Windows e i separatori POSIX, con test per i casi indicati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, sqlite
- Ambito
- databases
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100