Posts by Ernesto Casanova • 1,344 points
84 posts
-
0
votes1
answer144
viewsA: How to draw a draw for an element of an array within a specific range?
Hello alive beyond Random there are more options.... randrange and Uniform for integers and for floats. Your example with both, adjust to what you need. from random import randrange, uniform #…
-
0
votes1
answer203
viewsA: Name error: name 'variable' is not defined
Hello alive without realizing what this code is for, I can correct what is wrong.... first you cannot access the variable Perd because it is in the Scope of a function, ie will be used at the time…
pythonanswered Ernesto Casanova 1,344 -
0
votes1
answer40
viewsA: SQL performance when dividing results into categories
Perform filter by category reduces to the maximum your result otherwise you will return millions of records and you will not be able to put in memory, additionally check if you have index in this…
-
0
votes2
answers2134
viewsA: Make input accept only positive numbers
Hello removes the initial INT conversion and does the conversion after validating.... so: n = input('Digite um numero para calcular seu fatorial ' ) if not n.isdigit(): print("Digite apenas…
pythonanswered Ernesto Casanova 1,344 -
1
votes1
answer1541
viewsA: To assign the value 0 to a query by returning NULL SQL
In SQL Server allows the use of the ISNULL function, which validates if the output is null and closes the default you set. Together I share your query for SQL Server, Mysql and Oracle. SQL Server…
-
1
votes2
answers62
viewsA: Optimization in SQL
Hello live based on the previous answers perform the query using IN and create indexing if it does not exist, the complete solution to optimize your query. Consultation SELECT products.name,…
-
2
votes2
answers85
viewsA: How to use methods of an object within "with" in Python?
In Python "with" is a context manager created to manage "Unmanaged-Resources", more details context-manager and Unmanaged-Resources. In short, the use of context managers is widely used, and should…
pythonanswered Ernesto Casanova 1,344 -
0
votes1
answer59
viewsA: Datatype Conversion Query - Varchar to Float
Test if this solves your problem, using the Mysql TRIM function, you have HERE the documentation. Query SELECT TRIM(TRAILING '0' FROM `16_remuneracao_sem_13`)+0 FROM `t_trabalhador`;…
-
0
votes3
answers279
viewsA: use of cursor to update item to item stock
I share an example of creating temp table. Next I share an example of cursor...I share an example and you adjust it to your case. Create TEMP Table IF(OBJECT_ID('#ID_Table') IS NULL) BEGIN --IF NULL…
-
0
votes1
answer138
viewsA: Trigger which arrow default value for a field
I validated with Sqlfiddle, I do not have Oracle on my machine. When entering the record without the DPT_ID column sets the default 20. CREATE TABLE DEPARTAMENTO ( ID NUMBER PRIMARY KEY, NOME…
-
0
votes1
answer75
viewsA: How to detect that two bodies (in my case, balls) have touched while they are moving?
Hello viva uses so although this solution only reflect the change of direction on the X axis, you can change how you want it to be, however with this function that I share will stop colliding as you…
-
1
votes2
answers115
viewsA: How to return attribute value X - in a Manytomanyfield
Good in M2m ratio, you can use it like this: py.models class Atividade_estruturas_complementares(models.Model): atividades_complementares = models.ManyToManyField(Atividade) class Meta:…
-
0
votes1
answer55
viewsA: Return zero when no record is found
Hello as already mentioned you should put which database, I assume it is Mysql, I share what seems to me to be the solution, although you do not have much information: SELECT AA.ZZV_FILIAL,…
sqlanswered Ernesto Casanova 1,344 -
1
votes1
answer49
viewsA: Show only 1 secondary table record along with primary table on cursor
Hi viva sharing more information as you already suggested. I share here a simple example how to create a temp table with SQL Server. I also share how to remove at end of use: Create TEMP Table…
-
0
votes2
answers750
viewsA: How to pick up *ngFor Angular 7 item
Use thus based in this example. HTML <!-- Form starts --> <form [formGroup]="registrationForm" (ngSubmit)="onSubmit()"> <select class="form-control"…
-
0
votes2
answers79
viewsA: Pivot with Temporary Table
Hello you have here the solution, SELECT TCK_SEQUENCIAL, [1] AS CAT_NUMERO_1, [2] AS CAT_NUMERO_2, [3] AS CAT_NUMERO_3, [4] AS CAT_NUMERO_4 FROM ( SELECT TCK_SEQUENCIAL, CAT_NUMERO, CAT_VALOR FROM…
-
0
votes2
answers799
viewsA: Direct image upload to BD Mysql using C#
Hello alive as already indicated the best practice is to save the images in the folder published on the server or in a block. I share additional details to compare based on my experience: DB The…
-
1
votes2
answers191
viewsA: Table with dynamic columns
The way json is structured you won’t be able to directly get the expected result, however with DOM (CSS) manipulation you can get there. Without much attention with layout, your example fixed and…
angularanswered Ernesto Casanova 1,344 -
0
votes3
answers84
viewsA: Two classes in a Register screen
The line I added to the.py urls, plus Forms.py, with the Alunoview class is that Django can load with the GET a form request to the view: urls url(r'^cadastra', app.forms.AlunoView.as_view(),…
-
4
votes3
answers214
viewsA: Error: "Return should not be followed by an object expression"
Take a look around here, if you search for the error code you find the explanation, problem, in a "void" function can not return anything, you are returning a boolean. It will be rather this....…
-
0
votes3
answers84
viewsA: Two classes in a Register screen
check if you put it like this: Already tested, look image: class cadform(ModelForm): SEX_CHOICES = ( ('F', 'Female',), ('M', 'Male',), ('U', 'Unsure',), ) sexo= forms.CharField(label='Select sex',…
-
0
votes1
answer183
viewsA: Default values in the model - Django
Considering a different table than User, there is nothing wrong with your code, what is missing is to run a command, you have to run, in this order: python Manage.py makemigrations python Manage.py…
-
0
votes1
answer294
viewsA: Generate PDF in Django admin
you have here an example of how to do this, you need to use an ACTION, something like this: from django.http import HttpResponse from django.template.loader import render_to_string from .models…
-
0
votes3
answers84
viewsA: Two classes in a Register screen
The database attribute "sex" is, like others, an SCD table (Slowly Changing Dimension), will not have major changes over time, so you can switch to CHOICES in Django. Then the options will be…
-
0
votes3
answers211
viewsA: Compare the widget with the rest of the Python list
I now put the most complete answer, with the class I used. class Usernames: @staticmethod def usernamesSystem(u): cont = 0 aDict = {} result = [] for i in range(len(u)): cont =…
-
0
votes3
answers211
viewsA: Compare the widget with the rest of the Python list
With Dictionary it is possible to store the names and the number of times you repeat: def usernamesSystem(u): cont = 0 aDict = {} result = [] for i in range(len(u)): cont = checkKey(aDict, u[i]) #…
-
1
votes3
answers196
viewsA: How to select to find a record between two values?
Well, your query would be something like this: SELECT juros FROM [tabela] where valor_min BETWEEN valor_min AND 2500 AND valor_max BETWEEN 2500 AND valor_max However, when I published I saw a query…
-
0
votes1
answer42
viewsA: insert xml record plus date into a time table
Here is the solution. But the temporary table needs to be created, you know how to create? DECLARE @hDoc int DECLARE @XML XML SET @XML = '<rows> <row> <tracking>…
-
1
votes1
answer78
viewsA: How to configure Mysql for multiple connections?
Mysql like other services (SQL Server, Oracle, etc.), as you just explained in your description, allows multiple queries. That is, the database engine receives the connections with the orders and…
-
0
votes1
answer344
viewsA: how to do total in list elements Python Django
I think you need to review your function a little bit, or we’ll see. The x of the Employee receives the SUM and returns in each iteration (??), if you want the gross you have to sum everything and…
-
1
votes2
answers73
viewsA: Calculating balance and separation by currency
the logic of the invoice and the balance would put this way. When I want N rows grouped in the result (in a single Row and column). , 'FATURA' = ISNULL( (SELECT STUFF((SELECT ', ' + F.[ID] FROM…
-
0
votes2
answers153
viewsA: Remove duplicity in two columns
From what I understand. I think you need something like this. SQL Server, give feedback if it helped. SELECT [data] ,cod_prod ,descricao ,(SELECT TOP 1 chave FROM [teste].[dbo].[products] B WHERE…
-
0
votes1
answer52
viewsA: problems with creating stored Procedure mssql
Hello replace the part you commented on by this code...I did not create the table to validate, but it will be something there. Validate and give feedback. DECLARE MSN_CURSOR CURSOR FOR SELECT * FROM…
sql-serveranswered Ernesto Casanova 1,344 -
2
votes3
answers2918
viewsA: pass input text value to an angle function
Hello hello hello, a way to access input can be as answered earlier, with 2 way Binding. <input [(ngModel)]="filtro" name ="filtro" class= "rounded mb-3" type="search" placeholder="search..."…
angularanswered Ernesto Casanova 1,344