Answer the question
In order to leave comments, you need to log in
How to open Sqlite3 database from Python?
Good day!
There is a task:
-Take data from the 1C Log file
-Create a flat table, based on several tables from the Log file (it is on the Sqlite3 engine), upload this beauty to CSV, for further manipulations
On the test log file, everything turned out to be hardcoded, the data is converted, recorded, uploaded in the right format to the right place.
I wanted to put the values of the variables in a separate file, in which case you can change the path to the Log file, the name of the CSV file where to upload, and so on, so as not to constantly climb into the script.
The first version looks like this:
import sqlite3
conn = sqlite3.connect('\\пусть-до-места-где-лежит\\1Cv8.lgd')
cursor = conn.cursor()
sql = "SELECT трали-вали..."
import sqlite3
#Конфиг
Config = open('\\Путь-до-"конфига"\\Config.ini')
LogFile = Config.readlines()[1] #Строка в которой прописан путь
conn = sqlite3.connect(LogFile)
cursor = conn.cursor()
Answer the question
In order to leave comments, you need to log in
I've only been learning Python for the second week.
It turned out that the .strip() method had to be added to LogFile = Config.readlines()[1]:
Config = open('\\Path-to-"config"\\Config.ini')
LogFile = Config.readlines() [1] .strip() #String containing the path
conn = sqlite3.connect(LogFile)
cursor = conn.cursor() Line feed was strictly passed
with elements \n
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question