53
votes
Accepted
Counting rows in a CSV file that correspond to a database row, each with a million records
Your inner loop appears to be unnecessary. Why not create a lookup:
...
20
votes
Singleton Database class
You shouldn't be sharing Connection instances, because ADO is already doing the job for you, it uses object pooling behind the ...
17
votes
17
votes
Console Library System in C++
Make variables and functions const where appropriate
You used const references in a few places, but you missed a lot of ...
14
votes
Accepted
My database class extends MySQLi
Note: I don't think this is what you want to hear. But I have to write "the truth". This is my personal opinions about your code.
Give me parameterized SQL or give me death!
tell me if ...
14
votes
Counting rows in a CSV file that correspond to a database row, each with a million records
The code appears to be broken, you're not break;ing after finding a match so all records will likely have row[12] == "N".
You ...
13
votes
13
votes
Accepted
Generalization of any() function with switchable default parameter for empty iterables
I really think this is a bad idea. A function called any returning True if there not only isn't anything true but even not ...
12
votes
Accepted
Simple customer program in C (using binary files)
I see a number of things that may help you improve your code.
Eliminate function prototypes by ordering
Since you put the acadd and ...
11
votes
Database Handler Class
Security
This code is not secure.
SQL Injection
You are trusting the user input completely (except in the login function where you do use ...
11
votes
Accepted
Simple text DataBase
Reduce duplicated logic by using helper methods
Instead of repeating this condition:
if (file.getName().endsWith(mime)) {
Use a helper method:
...
11
votes
Singleton Database class
Just commenting on ... the comments in the source (sorry): I think they add a lot of noise, and don't provide any improved clarity (in this case). They're mostly restating what the following line of ...
11
votes
Inserting a DBNull value into a database
The most terse and declarative way to write this is to use C#'s ?? operator. Your line becomes:
...
10
votes
Accepted
Key value flat file system - single header INI replacement
Let's start with your priorities: optimization. You should be primarily optimizing for the most expensive and limited resource, which is almost always developer brain cycles. You optimize for that ...
10
votes
Creating Original Database Algorithm--Login System
It looks like passwords are stored in plain text form in the pswd.txt file. Never ever store passwords in plain text form. Store passwords salted and cryptographically hashed. That way, if an attacker ...
10
votes
Accepted
Generic asynchronous SQLite search builder
Reflection is slow. That line probably doesn't help your performance :
var model = (T)Activator.CreateInstance(typeof(T));
I notice that you always create your ...
10
votes
Accepted
Inserting a DBNull value into a database
All you have to do is to use the ?: (ternary operator):
...
10
votes
Accepted
Reducing the amount of duplicated code (python) - cricket matches
Disclaimer: I know nothing whatsoever about the rules of cricket.
Useless check
Because either info['toss_decision'] equals ...
9
votes
Accepted
Example script for teaching DDL and CRUD/DML operations
Also said before, but I think it worth mentioning again: there is not need for prefix_ for all columns. As far as I know, Hungarian and Leszynski notations are not exactly recommended. Since column ...
9
votes
Event scheduler in C
Self-documenting code
char h1 = { (e.hour / 10) + '0' }; // Extract the first digit and convert to char (if any, else 0)
As you considered the division by ten ...
9
votes
Accepted
LinDB: A dictionary type database
Both impressive and ambitious!
Passwords
the absolute requirement of a 32 character long password ensures it will take a considerable amount of time to break the encryption
It will also ensure that ...
9
votes
Generalization of any() function with switchable default parameter for empty iterables
Any and All
If you are going to override any(...) to return a custom result when given an empty iterable, you should also override ...
9
votes
Accepted
Embedded IoT: local data storage when no network coverage
We're missing an include of <stdint.h> in the header, and <stdbool.h> in the implementation.
Some parts of the code ...
8
votes
Having a class return a single database instance or list of all database instances
First, I don't like the concept of mixing "Models" with "Repository".
One principle that, from my point of view, should be followed, is the Single Responsibility (the S in SOLID). It means that one ...
8
votes
Accepted
Summing the prices from Transaction files
Nitpicks
There is a slight amount of inconsistency in your capitalization of keywords. SUM() / sum() and ...
8
votes
Accepted
Manage connection without 'using' statement
I can understand why you want to remove the clutter from your code - but sharing the instance of MySqlConnection isn't a good idea. As soon as multiple threads are ...
8
votes
Accepted
Creating Original Database Algorithm--Login System
In your function pick_password, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with ...
8
votes
Marijuana information program
Everything is a String
Welcome to Java and object-oriented programming! You are doing something really strange in Java in your ...
8
votes
Use PreparedStatement to insert into H2 database
There are some things to improve in this code. Especially when it's underlined that "if it can be maintained later on".
SQL query
The columns where the data will be inserted should always be defined,...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
database × 543c# × 105
sql × 98
python × 91
php × 87
mysql × 69
java × 67
performance × 46
object-oriented × 46
beginner × 38
sqlite × 24
django × 23
python-3.x × 22
pdo × 21
javascript × 20
sql-server × 20
postgresql × 18
c++ × 16
c × 15
entity-framework × 15
ruby × 13
.net × 12
design-patterns × 11
ruby-on-rails × 11
node.js × 10