From c79051b544c3e9b0a4bf8355e6d775092b37372c Mon Sep 17 00:00:00 2001 From: sam <318597anton> Date: Wed, 13 Jul 2022 15:48:01 +0400 Subject: [PATCH] fix datetime --- datetime.json | 2 +- main.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/datetime.json b/datetime.json index aa8d765..055beff 100644 --- a/datetime.json +++ b/datetime.json @@ -1 +1 @@ -"2022-06-06 18:23:00.7168350" +"2022-06-24 22:11:28.713372" diff --git a/main.py b/main.py index f170a12..85a2a5d 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,30 @@ import json -from datetime import datetime +from datetime import datetime, timedelta import pyodbc import requests from bs4 import BeautifulSoup + +messageTo = {'sam': '331491581', 'is': '-1001637207513'} +driverFrom = {'lxc': '/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1}', 'windows': '{ODBC Driver 17 for SQL Server}'} + + server = '10.3.1.13\SQLEXPRESS' database = 'DepartmentDatabaseContext' username = 'sa' password = 'isadmin' cnxn = pyodbc.connect( - 'DRIVER={/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1};SERVER=' + server + ';' + + 'DRIVER=' + driverFrom.get('lxc') + ';SERVER=' + server + ';' + 'DATABASE=' + database + ';UID=' + username + ';PWD=' + password + ';Encrypt=no') -messageTo = {'sam': '331491581', 'is': '-1001637207513'} def main(): with open('datetime.json') as json_file: - date = json.load(json_file) + strDatetime = json.load(json_file) + date = datetime.fromisoformat(strDatetime) + timedelta(microseconds=10) + #MS SQL хранит на одно значение больше в микросекундах, поэтому 713372 (Python) < 7133722 (MS SQL) + cursor = cnxn.cursor() cursor.execute("SELECT Id, Title, Body, DateCreate FROM Newses "