url = URL.create(
drivername="access+pyodbc",
query={
"odbc_connect": connStr,
},
)
with create_engine(url).connect() as con:
sql_get_anag = text(f"SELECT Tipo_Presenza FROM Presenza WHERE ID_Anagrafica = {IDValue} AND Giorno > {current_day_insert} AND Giorno < {current_day_insert_1}")
Presenza_tab = pd.read_sql_query(sql_get_anag, con)
这将返回以下错误:
Exception has occurred: ProgrammingError
(pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00'. (-3100) (SQLExecDirectW)")
[SQL: SELECT Tipo_Presenza FROM Presenza WHERE ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00]
(Background on this error at: https://sqlalche.me/e/20/f405)
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00'. (-3100) (SQLExecDirectW)")
url = URL.create(
drivername="access+pyodbc",
query={"odbc_connect": connStr,}
)
with create_engine(url).connect() as conn:
query = text("""
SELECT
Tipo_Presenza
FROM
Presenza
WHERE
ID_Anagrafica = :id_value
AND Giorno > :current_day
AND Giorno < :current_day_1
"""
)
result = conn.execute(
query,
{
'id_value': IDValue,
'current_day': current_day_insert,
'current_day_1': current_day_insert_1
}
)
df = pd.DataFrame(result, columns=result.keys())
另外,我认为您真的不想 create_engine 这样使用。您应该创建一次引擎然后使用, with engine.connect() as conn 以避免每次建立引擎的开销。
Dim tVar As Variant
QNumber = "Q" & Format(Me![CustomerID], "00") & Format(Now(), "ddmmyy")
tVar = DLast("[QuotationNumber]", "someTableName", "[QuotationNumber] like '" & QNumber & "*'")
If IsNull(tVar) Then
' no record found so it's a new day
QNumber = QNumber & "01"
Else
' There is a previous record for this customer and this day so just add one
QNumber = QNumber & Format(Val(Right(tVar, 2)) + 1, "00")
End If
rs("QuotationNumber") = QNumber
我已将后端移至 sharepoint 并创建了一个名为 Images 的文件夹。该文件夹位于文档文件夹中。链接字符串的形式为: https://webname365.sharepoint.com/sites/SECS-Department 我想使用文件对话框将文件上传到文档文件夹中的 Images 文件夹。 https://webname365.sharepoint.com/sites/SECS-Department/Shared Documents/Images/ 我四处查看,发现使用 REST API 似乎是执行此操作的最佳方法。我偶然发现 https://.com/questions/75285008/vba-upload-of-file-to-sharepoint-using-rest-api-download-already-implemented-in 并尝试对其进行修改,但出现错误“404 NOT FOUND”有人能帮我解决这个问题吗?
Private Sub uploadImage_Click()
Dim ado As Object
Dim ofd As Object
Dim filePath As String
Dim strExt As String
Dim newFileName As String
Dim strBackEndPath As String
Dim i As Integer
Dim SharePointURL As String
strBackEndPath = CurrentDb.TableDefs("tblEquipment").Connect
i = InStrRev(strBackEndPath, "DATABASE=") + Len("DATABASE=")
SharePointURL = Mid(strBackEndPath, i, InStr(i, strBackEndPath, ";") - i) & "/Shared Documents/Images/"
SharePointURL = Replace(Mid(strBackEndPath, i, InStr(i, strBackEndPath, ";") - i) & "/Shared Documents/Images/", " ", "%20")
Set ofd = Application.FileDialog(3)
ofd.AllowMultiSelect = False
ofd.Show
If ofd.SelectedItems.Count = 1 Then
filePath = ofd.SelectedItems(1)
strExt = Mid(ofd.SelectedItems(1), InStrRev(ofd.SelectedItems(1), "."))
If strExt = ".jpeg" Then
strExt = ".jpg"
End If
newFileName = ReplaceSpecialChars(Me.itemName.Value, "-") & "_" & ReplaceSpecialChars(Nz(Me.Model.Value, ""), "-") & strExt
Debug.Print filePath
Debug.Print newFileName
Debug.Print SharePointURL
Set ado = CreateObject("ADODB.Stream")
With ado
.Type = 1 'binary
.Open
.LoadFromFile filePath
.Position = 0
End With
Dim client As Object
Set client = CreateObject("MSXML2.XMLHTTP.6.0")
With client
.Open "POST", SharePointURL & newFileName, False
.send ado.read
ado.Close
Debug.Print .responseText
If .Status = 200 Then '200 = OK
MsgBox "Upload completed successfully"
Else
MsgBox .Status & ": " & .StatusText
End If
End With
Else
MsgBox "Image update Cancel!"
End If
End Sub