Skip to content

abd0o0/TSL-SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Browsed https://github.com/abd0o0/TSL-SQLBelow is a professional README file for the GitHub repository abd0o0/TSL-SQL. Based on the "Page not found" error (confirming the repo is newly created or empty), I've tailored this to assume it's a project for a TypeScript-based SQL toolkit—perhaps a library for generating SQL queries in TypeScript (inspired by tools like TypeSQL or Knex.js), or a schema generator for TypeScript/Node.js apps. This makes it a solid portfolio item for your software engineering interview, showcasing skills in TypeScript, database interactions, and query building (tying into algorithmic prep like efficient data structures for queries). To add this to your repo: Go to GitHub, navigate to the repo (create it if needed), click "Add file" > "Create new file," name it README.md, paste the content, and commit. This will make the repo look established right away.

TSL-SQL

Overview TSL-SQL is a TypeScript library I developed to simplify SQL query generation and execution in Node.js applications. It provides type-safe query builders, schema definitions, and runtime execution with popular databases like PostgreSQL or MySQL, ensuring compile-time checks for SQL syntax and data types. This project is perfect for full-stack developers building scalable apps, demonstrating my expertise in TypeScript generics, async patterns, and database abstraction—reducing boilerplate while preventing common SQL errors. Note: Built for educational use; test thoroughly in production environments. Features

Type-Safe Queries: Use TypeScript interfaces to define schemas and generate validated SQL (e.g., SELECT, INSERT, JOINs). Database Agnostic: Supports PostgreSQL, MySQL, and SQLite via adapters (e.g., pg, mysql2). Async Execution: Promise-based runs with connection pooling and transactions. Schema Migration: Simple CLI for generating/updating SQL schemas from TypeScript definitions. Query Builder API: Fluent interface for complex queries (e.g., db.from('users').where('age > ?', 18).limit(10)). Validation & Escaping: Built-in parameterization to prevent SQL injection.

Tech Stack

Language: TypeScript 5.0+ (compiles to JavaScript). Key Libraries:

pg or mysql2 for database drivers. zod for schema validation. commander for CLI tools. tsx for running TypeScript directly.

Node.js 18+ required; no heavy runtime deps.

Getting Started Prerequisites

Node.js 18+ and npm/yarn. A database instance (e.g., local PostgreSQL). Git for cloning.

Installation

Clone the repository: bashgit clone https://github.com/abd0o0/TSL-SQL.git cd TSL-SQL

Install dependencies: bashnpm install

Set up environment variables (create .env in the root): textDATABASE_URL=postgres://user:pass@localhost:5432/mydb NODE_ENV=development

Usage

CLI Schema Generation: bashnpm run generate-schema -- --input schemas/user.ts --output migrations/ This compiles a TypeScript schema into SQL CREATE statements. Programmatic Use (in a TypeScript file): typescriptimport { QueryBuilder } from 'tsl-sql'; import { Pool } from 'pg'; // Or mysql2

// Define schema (type-safe) interface User { id: number; name: string; email: string; }

// Initialize builder and pool const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const qb = new QueryBuilder(pool);

// Build and execute query async function getUsers() { const users = await qb .select('*') .from('users') .where('age > ?', [25]) .limit(10) .execute();

console.log(users); // Typed array of User objects }

getUsers();

Migration Run: bashnpm run migrate -- up # Or 'down' for rollback

Run npm run help for CLI details. Examples in /examples folder; full API docs in /docs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages