fix datetime
This commit is contained in:
parent
d36d46d409
commit
c79051b544
@ -1 +1 @@
|
|||||||
"2022-06-06 18:23:00.7168350"
|
"2022-06-24 22:11:28.713372"
|
||||||
|
15
main.py
15
main.py
@ -1,23 +1,30 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import pyodbc
|
import pyodbc
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
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'
|
server = '10.3.1.13\SQLEXPRESS'
|
||||||
database = 'DepartmentDatabaseContext'
|
database = 'DepartmentDatabaseContext'
|
||||||
username = 'sa'
|
username = 'sa'
|
||||||
password = 'isadmin'
|
password = 'isadmin'
|
||||||
cnxn = pyodbc.connect(
|
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')
|
'DATABASE=' + database + ';UID=' + username + ';PWD=' + password + ';Encrypt=no')
|
||||||
|
|
||||||
messageTo = {'sam': '331491581', 'is': '-1001637207513'}
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with open('datetime.json') as json_file:
|
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 = cnxn.cursor()
|
||||||
cursor.execute("SELECT Id, Title, Body, DateCreate FROM Newses "
|
cursor.execute("SELECT Id, Title, Body, DateCreate FROM Newses "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user