This file contains hidden or 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 Database from 'better-sqlite3'; | |
| import { createDatabaseClient } from './proxy.ts'; | |
| // 1) Create an in-memory DB and your table(s). | |
| const db = new Database(':memory:'); | |
| db.exec(` | |
| CREATE TABLE users ( | |
| id TEXT PRIMARY KEY, | |
| data JSON | |
| ); |
This file contains hidden or 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
| /** | |
| * @param { import("knex").Knex } knex | |
| * @returns { Promise<void> } | |
| */ | |
| exports.up = function (knex) { | |
| return Promise.all([ | |
| refConstants(knex), | |
| VendorsTransactionTable(knex) | |
| ]); | |
| } |
This file contains hidden or 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
| from configs.db_connection import release_conn | |
| from pydantic import BaseModel | |
| from psycopg2 import sql, extras | |
| import logging | |
| from constants.function_debug_codes import db_query_codes | |
| from constants.app_constants import __ENV__ | |
| import traceback | |
| async def get_rows( |
This file contains hidden or 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
| export async function uniqueConstraintCheck( | |
| connection: typeof dbConnection, | |
| { | |
| tbl, | |
| select, | |
| whereCol, | |
| whereValue, | |
| input | |
| }: any) { | |
| const eCode = genQueryCodes["uniqueConstraintCheck"] |
This file contains hidden or 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
| async def update_many_columns( | |
| cursor, tbl, new_data, where_col, where_value,limit=None, returning=None | |
| ): | |
| debug_code = db_query_codes["update_many_columns"] | |
| try: | |
| query = sql.SQL("UPDATE {tbl} SET {new_data} WHERE {where_col} = {where_value}").format( | |
| tbl=sql.Identifier(tbl), | |
| where_col=sql.Identifier(where_col), | |
| where_value=sql.Literal(where_value), |
This file contains hidden or 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
| const exportReq = useMutation(exportDataRemote, { | |
| onSuccess: (data) => { | |
| var file = window.URL.createObjectURL(data); | |
| var a = document.createElement('a'); | |
| a.href = file; | |
| a.download = "donations.csv"; | |
| document.body.appendChild(a); | |
| a.click(); | |
| a.remove(); | |
| console.log(file); |
This file contains hidden or 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 json | |
| import psycopg2 | |
| # Load JSON data from file | |
| with open('data.json') as f: | |
| data = json.load(f) | |
| # Establish a database connection | |
| conn = psycopg2.connect(dbname='test_db', user='postgres', password='password', host='127.0.0.1') | |
| cur = conn.cursor() |
This file contains hidden or 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
| const distibutionReq = useMutation(exportDataRemote, { | |
| onSuccess: (data) => { | |
| var file = window.URL.createObjectURL(data); | |
| var a = document.createElement('a'); | |
| a.href = file; | |
| a.download = "distribution.csv"; | |
| document.body.appendChild(a); | |
| a.click(); | |
| a.remove(); | |
| console.log(file); |
This file contains hidden or 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
| async def update_many_columns( | |
| cursor, tbl, new_data, where_col, where_value,limit=None, returning=None | |
| ): | |
| try: | |
| query = sql.SQL("UPDATE {tbl} SET {new_data} WHERE {where_col} = {where_value}").format( | |
| tbl=sql.Identifier(tbl), | |
| where_col=sql.Identifier(where_col), | |
| where_value=sql.Literal(where_value), | |
| new_data=sql.SQL(", ").join( | |
| sql.Composed( |
This file contains hidden or 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
| export function useIsScreenReady() { | |
| const [screenReady, setScreenReady] = useState(false); | |
| useEffect(() => { | |
| InteractionManager.runAfterInteractions(() => { | |
| setScreenReady(true); | |
| }); | |
| }, []); | |
| return screenReady; | |
| } |
NewerOlder