SQL examples for SQL Server
The ZappySys API Driver is a user-friendly interface designed to facilitate the seamless integration of various applications with the Google Drive API. With its intuitive design and robust functionality, the ZappySys API Driver simplifies the process of configuring specific API endpoints to efficiently read or write data from Google Drive.
On this page you will find some SQL examples which can be used for API ODBC Driver or Data Gateway API Connector.
Get my drive information
Gets my drive information
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Drive';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List all shared drives
List all shared drives
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM SharedDrives --WITH(Query=''name = "HR"'')';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get information about shared drive
Get information about shared drive
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM SharedDrives WITH(Query=''name = "HR"'')';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List / search files from my drive
List or search files from my drive (use search query expression). Uncomment Query part to invoke filter
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Files
WITH(
--Query=''name contains "ZappySys*.*"'', --includes files where name contains "zappysys" word
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List / search files from a single shared drive
List or search files from a specific shared drive by driveId and search query expression. Uncomment Query part to invoke filter
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Files
WITH(
--Query=''name contains "ZappySys*.*"'', --includes files where name contains "zappysys" word
DriveId=''0AFWIggplk2z6Uk9PVA'',
DriveType=''drive'',
SupportsAllDrives=''true'',
IncludeItemsFromAllDrives=''true''
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List / search files from all shared drives
List or search files from all shared drives by driveId and search query expression. Uncomment Query part to invoke filter
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Files
WITH(
--Query=''name contains "ZappySys*.*"'', --includes files where name contains "zappysys" word
DriveType=''allDrives'',
SupportsAllDrives=''true'',
IncludeItemsFromAllDrives=''true''
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List / search items (files/folders) from a parent folder in recursive or non-recursive mode
This example shows how to list files from a parent folder, optionally you can specifiy item types to list (e.g. files, folders, sheets, documents). If you do not specify FolderId then recursive list is returned.
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM list_parent_items
WITH(
--Parent folder id (Keep it blank to scan all files in all folders - recursive
FolderId=''1VK5NBhuOTaLEy1pBMsQtG672vrJNgxai''
--List only from Trash (deleted files)
, IncludeFromTrash=''false''
--Extra search criteria
--, Query=''or (name contains ''''blog'''') or (name contains ''''test'''') '' --extra query
--Item type to return (default is all)
--, ItemType=''files'' -- (default=all) all, files, folders, sheets, documents, files_native, files_exclude_native
--, ItemType=''folders''
--, ItemType=''sheets''
--, ItemType=''files_native''
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Dowload a file (my drive)
Downloads a file (from user my drive)
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM download_file
WITH(Id=''1PpE2eSi5faAnMwiSolwr34zA5MwOdR3D''
,ResponseDataFile=''C:\MyFiles\myfile.ext''
)
--You can get file Id by selecting from ''list_files'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Dowload a file from google shared drive
Dowload a file from google shared drive for which user has access
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM download_file
WITH(
DriveType=''drive'' --or set ''user'' for mydrive
, DriveId=''0AFWIggplk2z6Uk9PVA''
, Id=''1hk7odj2Y2--yxN9DY0zW88hSnxqiyHq0'' --file id
, ResponseDataFile=''c:\temp\dump.zip''
--You can get file Id by selecting from ''list_files'' endpoint
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Upload local file to google shared drive folder (Overwrite if exists)
Upload a local file to google shared drive folder for which user has access. Donot set DriveId to upload to MyDrive rather than sahred drive.
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM upload_file_overwrite
WITH(
DriveId='''' --for my drive keep blank
--DriveId=''0AC00HWQH144cUk9PVA'' --team drive id (keep blank for uploading to my drive)
, DiskFilePath=''C:\temp\dump.csv'' --source file path
, FileName=''dump.csv'' --target file name
, ParentFolderId=''root''
--OR--
--, ParentFolderId=''1PRySfNNjWIp9ZAnhPh-u9tKRj3QOETSq''
--, FileOverwriteMode=''AlwaysOverwrite''
--OR--
--, FileOverwriteMode=''FailIfExists''
--, KeepRevisionForever=''false''
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get file list
Downloads a file
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Files';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Update a file
Updates a file
DECLARE @MyQuery NVARCHAR(MAX) = 'UPDATE Files
WITH (Id=''1EVzXFVBQIh3LcJvfcLhI1UWhW3qUxFkM''
,DiskFilePath=''C:\MyFiles\myfile.ext'')
--You can get file Id by selecting from ''list_files'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Delete a file
Deletes a file
DECLARE @MyQuery NVARCHAR(MAX) = 'DELETE FROM Files
WITH (Id=''1gcu0hV34OTfgvcu9CFhr7Go4b35j5Mop'')
--You can get file Id by selecting from ''list_files'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Delete a file by name from a shared drive
Delete a file by name from a shared drive
DECLARE @MyQuery NVARCHAR(MAX) = 'DELETE FROM Files where Name=''dump.csv'' and Trashed=0 WITH(DriveId=''0AC00HWQH144cUk9PVA'', DriveType=''drive'')
--You can get file Id by selecting from ''list_files'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Upload a file with INSERT keyword
Upload a file with INSERT keyword. Advantage of INSERT is you can use Bulk option using SOURCE clause. This way you can upload many files
DECLARE @MyQuery NVARCHAR(MAX) = 'INSERT INTO Files
WITH (FileName=''My filename''
,DiskFilePath=''C:\MyFolder\Mymyfile.ext''
,ParentFolderId=''root''
)
--You can get ParentFolderId by selecting from ''list_folders'' endpoint or just use ''root''';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Delete a folder
Deletes a folder
DECLARE @MyQuery NVARCHAR(MAX) = 'DELETE FROM Folders
WITH (Id=''1yDO11prsLH9DUrBTCadV6GGMJrITjF9I'')
--You can get folder Id by selecting from ''list_folders'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Create a folder
Creates a folder
DECLARE @MyQuery NVARCHAR(MAX) = 'INSERT INTO Folders
WITH (Name=''My folder name''
,ParentFolderId=''root'')
--You can get ParentFolderId by selecting from ''list_folders'' endpoint or just use ''root''';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get file information
Gets file information
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM FileInfo
WITH (Id=''1EVzXFVBQIh3LcJvfcLhI1UWhW3qUxFkM'')
--You can get file Id by selecting from ''list_files'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get items list
Gets items list
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM ItemsList';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get items list using query
Gets items list using query
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT Id, Kind, Name, MimeType
FROM list_items
WITH (Query = ''name contains ''''.txt'''''')';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get files list
Gets files list
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM FilesList';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Get folders list
Gets folders list
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM FoldersList';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Select from trash
Shows deleted items in Trash
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Trash';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
List files from trash for a shared drive
Shows deleted items in Trash
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Trash
WITH(
DriveType=''drive''
,DriveId=''1j0HFOP4gsoExxxxxx'' --get id from select * from SharedDrives
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Empty trash bin
Empties trash bin
DECLARE @MyQuery NVARCHAR(MAX) = 'DELETE FROM Trash';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Empty trash bin for a shared drive
Empties trash bin for a specified shared drive
DECLARE @MyQuery NVARCHAR(MAX) = 'DELETE FROM Trash
WITH(
DriveType=''drive''
,DriveId=''1j0HFOP4gsoExxxxxx'' --get id from select * from SharedDrives
)';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Export Google Sheet to Excel (xlsx) or PDF
Export a Google files to other format (e.g. Google Sheets to MS Excel / PDF)
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT "Status" FROM export_file
WITH(
Id=''1j0HFOP4gsoE-Zbf2xN3IsPSj8wgwNtIfyyvM1_BWkW4'' --//google sheet id or document ID
--,DriveId=''xx your shared drive id'' --get id from select * from SharedDrives
--,DriveType=''drive''
, ExportAs=''application/vnd.openxmlformats-officedocument.spreadsheetml.sheet''
--, ExportAs=''application/pdf''
, ResponseDataFile=''c:\temp\sheet1.xlsx''
, FileOverwriteMode=''AlwaysOverwrite'' -- or try ''FailIfExists'' or ''SkipIfExists''
))
--You can export files from ''export_file'' endpoint';
EXEC (@MyQuery) AT [LS_TO_GOOGLE_DRIVE_IN_GATEWAY];
Learn more about this SQL query.
Getting Started with Examples
ZappySys API Driver is a powerful software solution designed to facilitate the extraction and integration of data from a wide range of sources through APIs. Its intuitive design and extensive feature set make it an essential asset for any organization dealing with complex data integration tasks.
To get started with examples using ZappySys API Driver, please click on the following applications:
Key features of the ZappySys API Driver include:
The API ODBC driver facilitates the reading and writing of data from numerous popular online services (refer to the complete list here) using familiar SQL language without learning complexity of REST API calls. The driver allows querying nested structure and output as a flat table. You can also create your own ODBC / Data Gateway API connector file and use it with this driver.
Intuitive Configuration: The interface is designed to be user-friendly, enabling users to easily set up the specific API endpoints within Google Drive without requiring extensive technical expertise or programming knowledge.
Customizable Endpoint Setup: Users can conveniently configure the API endpoint settings, including the HTTP request method, endpoint URL, and any necessary parameters, to precisely target the desired data within Google Drive.
Data Manipulation Capabilities: The ZappySys API Driver allows for seamless data retrieval and writing, enabling users to fetch data from Google Drive and perform various data manipulation operations as needed, all through an intuitive and straightforward interface.
Secure Authentication Integration: The driver provides secure authentication integration, allowing users to securely connect to the Google Drive API by inputting the necessary authentication credentials, such as API tokens or other authentication keys.
Error Handling Support: The interface is equipped with comprehensive error handling support, ensuring that any errors or exceptions encountered during the data retrieval or writing process are efficiently managed and appropriately communicated to users for prompt resolution.
Data Visualization and Reporting: The ZappySys API Driver facilitates the seamless processing and presentation of the retrieved data from Google Drive, enabling users to generate comprehensive reports and visualizations for further analysis and decision-making purposes.
Overall, the ZappySys API Driver serves as a powerful tool for streamlining the integration of applications with Google Drive, providing users with a convenient and efficient way to access and manage data, all through a user-friendly and intuitive interface.