public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{ }
public DbSet<Categoria> Categorias { get; set; }
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
TABLE_NAME, | |
COLUMN_NAME, | |
DATA_TYPE | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE TABLE_NAME = 'table'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://felipelauffer.com/2019/03/01/remover-acentos-e-cedilhas-de-uma-string/ | |
-- Usando COLLATE SQL_Latin, retira acentuação de string | |
SELECT 'çáéíóúâêîôûãõç' COLLATE SQL_Latin1_General_Cp1251_CS_AS AS nova_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
def main(): | |
password_length = int(input("Length (int) of password? ")) | |
punctuation_option = input("Punctuation on password? (y/n)") | |
if(punctuation_option == 'y'): | |
characters = list(string.ascii_letters + string.digits + string.punctuation) | |
else: | |
characters = list(string.ascii_letters + string.digits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Busca VARCHAR(8000) | |
SET @Busca = 'campo' | |
SELECT | |
Colunas.COLUMN_NAME, | |
Tabelas.TABLE_NAME | |
FROM | |
INFORMATION_SCHEMA.TABLES Tabelas | |
INNER JOIN INFORMATION_SCHEMA.COLUMNS Colunas | |
ON Tabelas.TABLE_NAME = Colunas.TABLE_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Weekly | |
-- first day of week, in this case, monday | |
DATEADD(DAY, 2 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)); | |
-- last day of week, in this case, sunday | |
DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)); | |
-- Monthly | |
-- first day of month | |
DATEADD(D,1,EOMONTH(GETDATE(),-1)); | |
-- last day of month |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// executando com node, npm -> package.json -> axios 1.3.4 | |
import axios from "axios"; | |
import fs from "fs"; | |
// config e req. tirado do postman | |
var config = { | |
method: "get", | |
maxBodyLength: Infinity, | |
url: "https://brasilapi.com.br/api/banks/v1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
import time | |
import concurrent.futures | |
def do_some(seconds = 1): | |
print(f'sleeping {seconds}') | |
time.sleep(seconds) | |
return f'done {seconds}' | |
if __name__ == '__main__': |
The _metadata attribute of the Pandas DataFrame was removed in version 1.3.0, which is why you are receiving a "list indices must be integers or slices, not str" error. The approach I suggested in my previous response would only work for Pandas versions earlier than 1.3.0.
In newer versions of Pandas, you can still access the compiled SQL statement by using the query attribute of the sqlalchemy.engine.ResultProxy object that is returned by pandas.read_sql_query. Here's an example:
import pandas as pd
from sqlalchemy import create_engine
# create a SQLAlchemy engine
engine = create_engine('postgresql://user:password@host:port/database')
OlderNewer